clear
clear mata
clear matrix

cd ..                                                                           /* Goes back to parent folder */

capture log close
log using "log/results-appendix.log", replace

mkdir tmp/

*       Patriotism!

*       FIRST VERSION  June	       2, 2022
*       THIS VERSION   June        9, 2022
*       LAST RUN       June	       9, 2022

*       AUTHOR              AT, BC
*       LAST REVISOR		LMC

*       Log of revisions:

*       This produces tables and figures in the appendix

***************************************************************************************************
****                              PLAN OF THE PROCEDURE                                        ****
****___________________________________________________________________________________________****
****                                                                                           ****
****     I. Tables                                                                             ****
****         Tab 1.  New Deal and Patriotism: Basic Patterns (Full)                             ****
****         	     Panel A: All Grants   						                               ****
****         	     Panel B: Breakdown    						                               ****
****         Tab 2.  Identification			                                    			   ****
****         Tab 3.  Balance table			                                    			   ****
****         Tab 4.  Reduced forms			                                    			   ****
****         Tab 5.  Placebo			                                    			       ****
****         Tab 6.  Mediation			                                    			       ****
****                 Panel A: New Deal grants                                			       ****
****                 Panel B: Agricultural grants                            			       ****
****         Tab 8.  Panel Regressions                                			               ****
****         Tab 9.  Frontier experience			                                    	   ****
****         Tab 10. Women volunteers			                                    		   ****
****         Tab 11. Spatial Autocorrelation                                                   ****
****                 Panel A: Moran's I                                      			       ****
****                 Panel B. Conley s.e.                                    			       ****
****         Tab 12. Entropy Balancing                                                         ****
****         Tab 13-15. Robustness in subsamples                                               ****
****         Tab 16. Inverse of 1930 population                                      		   ****
****         Tab 17. The Impact of Service Comamnd 7                                 		   ****
****     II. Figures                                                                           ****
****         Fig 1. Heterogeneity by cattle ranching                                		   ****
****         Fig 2. Never Takers                                                    		   ****
****         Fig 3. Heterogeneity: economic conditions                              		   ****
****         Fig 4. Heterogeneity: FDR support                                      		   ****
****         Fig 5. Distribution of droughts                                        		   ****
****         Fig 6. Heterogeneity: frontier experience                              		   ****
****         Fig 7. Plausibly Exogenous (Conley et al. 2012)                        		   ****
****         Fig 9. Matching Exercises                                              		   ****
****         Fig 10. Drop one state at a time                                        		   ****
****    III. Erase junk                                                                        ****
****___________________________________________________________________________________________****
***************************************************************************************************

macro def control  			 "ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC i.stateicpsr"
macro def control_ww1        "lpop10 c10unemp c10urban1 c10men c10black c10jap c10deu c10ita i.stateicpsr"
macro def control_nofe   	 "ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC"
macro def control_ww1_nofe   "lpop10 c10unemp c10urban1 c10men c10black c10jap c10deu c10ita"

macro def panelcontrols      "lpop unemp urban1 men black jap deu ita aut MEAN96282 vet2 lc40wage2 iwarconpro_PC2"

macro def controls_asn       "h w bmi C40NONWHITE C40MARRIED noncitizen C40SCHOOL_E  C40SCHOOL_H C40SCHOOL_C i.C40AGE"
macro def controls_asn_noage "h w bmi C40NONWHITE C40MARRIED noncitizen C40SCHOOL_E  C40SCHOOL_H C40SCHOOL_C"

********************************************************************************
****           0. Prepare datasets                                          ****
********************************************************************************  

********************************************************************************
****           		i. ASN                                      		    ****
******************************************************************************** 

/*
use "data\patriotism-ASN", clear

lab var iAAA_PF_farmer   				 "AAA grants $\times$ farmer"
lab var iAAA_PF_farmhand  				 "AAA grants $\times$ farm-hand"
lab var iAGRI_PF_farmer   				 "Agricultural support $\times$ farmer"
lab var iAGRI_PF_farmhand  				 "Agricultural support$\times$ farm-hand"
lab var iSUM3MO_DROUGHT3340_farmer    	 "Summer droughts: 1933-40 $\times$ farmer"
lab var iAGRI_T73_farmer 				 "Tenure in Agri committee: 1933-35 $\times$ farmer"
lab var iSUM3MO_DROUGHT3340_farmhand     "Summer droughts: 1933-40 $\times$ farm-hand"
lab var iAGRI_T73_farmhand  			 "Tenure in Agri committee: 1933-35 $\times$ farm-hand"
lab var farmer							 "Farmer"
lab var farmhand						 "Farm-hand"

save "tmp/asn", replace

*/

********************************************************************************
****           		ii. Main                                      		    ****
********************************************************************************   
use "data\patriotism", clear

/* new labels here and save version in tmp*/           

lab var lpop30         		"log 1930 population"
lab var c30unemp            "1930 unemployment rate"
lab var c40unemp            "1940 unemployment rate"
lab var lc40wage       		"log 1939 average wage"
lab var c30urban1           "Urban status: 1930"
lab var MEAN9628       		"Mean Democratic vote share: 1898-1928"
lab var c30men         		"1930 share of men"
lab var c30black       		"1930 share of blacks"
lab var c30jap         		"1930 share of Japaneses"
lab var c30deu        	 	"1930 share of Germans"
lab var c30ita         		"1930 share of Italians"
lab var c30vet         		"1930 share of veterans"
lab var invpop_w99     		"Inverse of 1930 population"
lab var c30farm        		"1930 farm share"
lab var iwarbond_1944_PC    "1944 war bond purchases p.c." 
lab var ww2_vol_pop40       "WWII volunteers per 1940 population"
lab var iwarconpro_PC       "WII war contract per capita"
lab var ww1_vol_sh          "WWI volunteering rate"
lab var ww1_vol_pop10       "WWI volunteers per capita"
lab var ww1_awards_pop10_is "WWI awards per capita"
lab var iYf_T29             "1929 farm income"
lab var shown_1930          "1930 share of farm-owners"
lab var iSUM3MO_DROUGHT3340 "Months of drought: 1933-40"
lab var iAGRI_T62           "Tenure agri committee: 1911-13"
lab var iAGRI_T73           "Tenure agri committee: 1933-35"
lab var iHOLC_PH            "HOLC loans"
lab var iinfra_AL           "Public works grants"
lab var iRFC_PC             "RFC loans"
lab var iNDEXP_PC      		"New Deal grants"
lab var iSSA_PB        		"Public Assistance"
lab var iAGRI_PF       		"Agricultural support"
lab var EW_AL          		"Emergency workers"
lab var tye_tfe890_500k_100_l6 "Frontier experience"
lab var ww2_awards_pop40_is "WWII medals per 1940 population"

save "tmp/patriot", replace


do "code-build/01_Shopping_List.do"
***************************************************************************************************
****         Tab 1.  New Deal and Patriotism: Basic Patterns (Full)                             ****
****         	     Panel A: All Grants   						                               ****
***************************************************************************************************

use "tmp/patriot", clear 

estimates clear
eststo: xi:  reg iwarbond_1944_PC   iNDEXP_PC $control if sample_ols == 1                      , r
	    qui: sum iwarbond_1944_PC   if e(sample) == 1, d
estadd local y_mean_round = string(r(mean), "%9.3f")
       local iqr_y       = (r(p75) - r(p25))
estadd local IQR_Y = string(`iqr_y', "%9.3f")
	    qui: sum iNDEXP_PC          if e(sample) == 1, d
       local iqr_x       = (r(p75) - r(p25))
estadd local IQR_X = string(`iqr_x', "%9.3f")

eststo: xi:  reg ww2_vol_pop40      iNDEXP_PC $control if sample_ols == 1 & servicecommand != 7, r
	    qui: sum ww2_vol_pop40      if e(sample) == 1, d
estadd local y_mean_round = string(r(mean), "%9.3f")
       local iqr_y       = (r(p75) - r(p25))
estadd local IQR_Y = string(`iqr_y', "%9.3f")
	    qui: sum iNDEXP_PC          if e(sample) == 1, d
       local iqr_x       = (r(p75) - r(p25))
estadd local IQR_X = string(`iqr_x', "%9.3f")


eststo: xi:  reg ww2_awards_pop40_is iNDEXP_PC $control if sample_ols == 1 & servicecommand != 7, r
	    qui: sum ww2_awards_pop40_is if e(sample) == 1, d
estadd local y_mean_round = string(r(mean), "%9.3f")
       local iqr_y       = (r(p75) - r(p25))
estadd local IQR_Y = string(`iqr_y', "%9.3f")
	    qui: sum iNDEXP_PC          if e(sample) == 1, d
       local iqr_x       = (r(p75) - r(p25))
estadd local IQR_X = string(`iqr_x', "%9.3f")

eststo: xi:  reg pc1                iNDEXP_PC $control if sample_ols == 1 & servicecommand != 7, r
	    qui: sum pc1                if e(sample) == 1, d
estadd local y_mean_round = string(r(mean), "%9.3f")
       local iqr_y       = (r(p75) - r(p25))
estadd local IQR_Y = string(`iqr_y', "%9.3f")
	    qui: sum iNDEXP_PC          if e(sample) == 1, d
       local iqr_x       = (r(p75) - r(p25))
estadd local IQR_X = string(`iqr_x', "%9.3f")


esttab using "results/tables/AppTab1A_main-full.tex" ,	                                               	   ///
	order(iNDEXP_PC           )           				  		                                           ///
	drop(_cons)                                                                                            ///
	indicate("State FE (48) = *state*")                   		                                           ///
	mgroups("War bonds" "Volunteers" "Medals" "PCA" , pattern(1 1 1 1 )                                    ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                      ///
			span erepeat(\cmidrule(lr){@span}) )			                                               ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	           ///
    scalars("y_mean_round Mean dependent variable") ///
	b(%9.3f) se(%9.3f) r2(%9.3f) substitute("\_" "_")                                                                ///
	nonotes nogaps title("Panel A. New Deal Spending and Patriotism: Full Estimates.}\label{tab:ols_full")

***************************************************************************************************
****         	     Panel B: Breakdown    						                               ****
***************************************************************************************************

estimates clear
eststo: xi:  reg iwarbond_1944_PC    iAGRI_PF iSSA_PB iinfra_AL EW_AL    iHOLC_PH iRFC_PC $control if sample_ols == 1                      , r
	    qui: sum iwarbond_1944_PC   if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40       iAGRI_PF iSSA_PB iinfra_AL EW_AL    iHOLC_PH iRFC_PC $control if sample_ols == 1 & servicecommand != 7, r
	    qui: sum ww2_vol_pop40      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is iAGRI_PF iSSA_PB iinfra_AL EW_AL    iHOLC_PH iRFC_PC $control if sample_ols == 1 & servicecommand != 7, r
	    qui: sum ww2_awards_pop40_is if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg pc1                 iAGRI_PF iSSA_PB iinfra_AL EW_AL    iHOLC_PH iRFC_PC $control if sample_ols == 1 & servicecommand != 7, r
	    qui: sum pc1                if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab1B_main-full.tex" ,	                                              	   ///
	order(iAGRI_PF iSSA_PB iinfra_AL EW_AL    iHOLC_PH iRFC_PC       )           				  	       ///
	drop(_cons)                                                                                            ///
	indicate("State FE (48) = *state*")                   		                                           ///
	mgroups("War bonds" "Volunteers" "Medals" "PCA" , pattern(1 1 1 1 )                                    ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                      ///
			span erepeat(\cmidrule(lr){@span}) )			                                               ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	           ///
    scalars("y_mean_round Mean dependent variable" )                                                       ///
	b(%9.3f) se(%9.3f) r2(%9.3f)                                                                           ///
	nonotes nogaps title(Panel B. New Deal Spending and Patriotism: Full Estimates.)
	

	
***************************************************************************************************
****         Tab 2.  Identification			                                    			   ****
***************************************************************************************************
estimates clear
eststo: xi:  reg iAGRI_PF             iSUM3MO_DROUGHT3340 iAGRI_T73 $control               if sample_ols == 1                      , cluster(CLIMDIVX)
		qui: sum iAGRI_PF
estadd local y_mean_round = string(r(mean), "%9.3f")
		qui: test                    iSUM3MO_DROUGHT3340 iAGRI_T73 
estadd local F_test       = string(r(F)   , "%9.1f")

eststo: xi:  reg iwarbond_1944_PC    iSUM3MO_DROUGHT3340 iAGRI_T73 $control               if sample_ols == 1                      , cluster(CLIMDIVX)
		qui: sum iwarbond_1944_PC      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40       iSUM3MO_DROUGHT3340 iAGRI_T73 $control               if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
		qui: sum ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is iSUM3MO_DROUGHT3340 iAGRI_T73 $control               if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
		qui: sum ww2_awards_pop40_is    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg pc1                 iSUM3MO_DROUGHT3340 iAGRI_T73 $control               if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
		qui: sum pc1                   if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")


esttab using "results/tables/AppTab2_id1.tex" ,	                                                                                   ///
    indicate("State FE (48) = *state*")                   		                                                                   ///
	order(iSUM3MO_DROUGHT3340 iAGRI_T73 ) drop(_cons)                                                                     ///
	mgroups("Agri support" "War bonds" "Volunteers" "Medals" "PCA" , pattern(1 1 1 1 1 )                                           ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
			span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
	mlabel("FS" "RF" "RF" "RF" "RF" )		                                                                                       ///
	scalars("y_mean_round Mean dependent variable" "F_test F-test of excluded instrument" )                                        ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
	b(%9.3f) se(%9.3f) r2(%9.3f) substitute("\_" "_")                                                                              ///
	nogaps title("Panel A. Identification: First Stage and Reduced Form Results: Full Estimates.}\label{tab:id_full") nonotes
	
estimates clear
eststo: xi:  ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1                      , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  iwarbond_1944_PC   if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi:  ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  ww2_vol_pop40      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  ww2_awards_pop40_is if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  pc1                if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab2_id2.tex" ,	                                                                               ///
    indicate("State FE (48) = *state*")                   		                                                                   ///
	order(iAGRI_PF ) drop(_cons)                                                                     ///
	mgroups("War bonds" "Volunteers" "Medals" "PCA", pattern(1 1 1 1 1 )                                                           ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
			span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
	mlabel("2SLS" "2SLS" "2SLS" "2SLS")		                                                                                       ///
	scalars("y_mean_round Mean dependent variable" "RA_test Rubin-Anderson test (p-value)")                                        ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
	b(%9.3f) se(%9.3f) r2(%9.3f)                                                                                                   ///
	nogaps title(Panel B. Identification: IV Results: Full Estimates) nonotes
***************************************************************************************************
****         Tab 3. Balance table			                                    			   ****
***************************************************************************************************	

local deps MEAN9628 ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30men c30black iYf_T29 c30farm c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC

local r = 0
forvalues s = 1/16{
	local dep: word `s' of `deps'
	local r = `r' + 1	
	
	estimates clear
	eststo: xi: reg `dep' iSUM3MO_DROUGHT3340 iAGRI_T73 i.stateicpsr if sample_ols == 1, cluster(CLIMDIVX)
	quietly     sum `dep' if e(sample) == 1 
	local e`r'1 = string(r(mean), "%9.3f")
	local e`r'4 = string(r(N), "%9.0f")

	local e`r'2a = string(e(b)[1,1], "%9.3f")
	
	local tmp = e(b)[1,1]/sqrt(e(V)[1,1])
	local tmp2 = 2*ttail(e(df_r),abs(`tmp'))
	if `tmp2' < .01{
		local e`r'2b = "$^{***}$"
	}
	if `tmp2' < .05 & `tmp2' > .01{
		local e`r'2b = "$^{**}$"
	}
	if `tmp2' < .1 & `tmp2' > .05{
		local e`r'2b = "$^{*}$"
	}
	
	local e`r'2 = "`e`r'2a'" + "`e`r'2b'"	

	local e`r'3a = string(e(b)[1,2], "%9.3f")
	
	local tmp = e(b)[1,2]/sqrt(e(V)[2,2])
	local tmp2 = 2*ttail(e(df_r),abs(`tmp'))
	if `tmp2' < .01{
		local e`r'3b = "$^{***}$"
	}
	if `tmp2' < .05 & `tmp2' > .01{
		local e`r'3b = "$^{**}$"
	}
	if `tmp2' < .1 & `tmp2' > .05{
		local e`r'3b = "$^{*}$"
	}
	
	local e`r'3 = "`e`r'3a'" + "`e`r'3b'"	

	
	local r = `r' + 1
	
	local e`r'2 = "["+string(sqrt(e(V)[`s',`s']), "%9.3f")+"]"
	local e`r'3 = "["+string(sqrt(e(V)[`s',`s']), "%9.3f")+"]"
	
}


preserve

clear
set obs 32
gen vars = ""
replace vars in 1 = "Democratic share 1896–1928"
replace vars in 3 = "WWI volunteering rate"
replace vars in 5 = "WWI awards per capita"
replace vars in 7 = "log 1930 population"
replace vars in 9 = "1930 unemployment rate"
replace vars in 11 = "1930 urban status"
replace vars in 13 = "1930 share of men"
replace vars in 15 = "1930 share of blacks"
replace vars in 17 = "1929 farm income (i.h.s.)"
replace vars in 19 = "1930 farm share"
replace vars in 21 = "1930 share of Japanese"
replace vars in 23 = "1930 share of Germans"
replace vars in 25 = "1930 share of Italians"
replace vars in 27 = "1930 share of veterans"
replace vars in 29 = "log 1939 average wage"
replace vars in 31 = "War contracts per capita (i.h.s.)"

gen avg = ""
lab var avg "Average"

gen drg = ""
lab var drg "Droughts"	
gen agc = ""
lab var agc "Agri Committee"
gen obs = ""
lab var obs "Observation} \tabularnewline & {(1)} & {(2)} & {(3)} & {(4)"

local y = 0
forvalues t=1/16{
	local y = `y' + 1
	
	replace avg in `y' = "`e`y'1'"
	replace drg in `y' = "`e`y'2'"
	replace agc in `y' = "`e`y'3'"
	replace obs in `y' = "`e`y'4'"

	local y = `y' + 1
	
	replace drg in `y' = "`e`y'2'"
	replace agc in `y' = "`e`y'3'"	

}
	
save "C:/X/tabbal", replace
texsave using "results\tables\AppTab3_balance_table", replace varlab align(lcccc) frag nofix width(0.87\textwidth) headerlines("& \multicolumn{4}{c}{Coefficient of:}") title("Balance Table.} \medskip \label{tab:balance") footnote( "\footnotesize \noindent \textit{Notes: } Balance table for the two instruments. Col 1: average of the variable listed on the left. Cols 2--3: each row reports the coefficients of separate regressions of the variable listed on the left on summer months of drought in 1933–40 and tenure in the Agricultural committee during the 73\textsuperscript{rd} Congress (both i.h.s.) and a full set of 48 state fixed effects. Standard errors clustered at climatic division level in brackets. *** p<0.01, ** p<0.05, * p<0.1.")
restore
	
***************************************************************************************************
****         Tab 4. Reduced forms			                                    			   ****
***************************************************************************************************	
estimates clear
eststo: xi:  reg iwarbond_1944_PC   iSUM3MO_DROUGHT3340            $control if sample_ols == 1                      , cluster(CLIMDIVX)
		qui: sum iwarbond_1944_PC      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40      iSUM3MO_DROUGHT3340            $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
		qui: sum ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is iSUM3MO_DROUGHT3340           $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
		qui: sum ww2_awards_pop40_is    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg pc1                 iSUM3MO_DROUGHT3340           $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
		qui: sum pc1                    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg iwarbond_1944_PC                       iAGRI_T73  $control if sample_ols == 1                      , cluster(DISTRICT_ID73)
		qui: sum iwarbond_1944_PC      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40                          iAGRI_T73  $control if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID73)
		qui: sum ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is                    iAGRI_T73  $control if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID73)
		qui: sum ww2_awards_pop40_is    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg pc1                                    iAGRI_T73  $control if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID73)
		qui: sum pc1                    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab4_rf.tex" ,	                                                                                   ///
	order(iSUM3MO_DROUGHT3340 iAGRI_T73 ) drop(_cons)                                                                              ///
indicate("State FE (48) = *state*")                   		                                                                       ///
	mgroups("War bonds" "Volunteers" "Medals" "PCA" "War bonds" "Volunteers" "Medals" "PCA", pattern(1 1 1 1 1 1 1 1)              ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
			span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
	scalars("y_mean_round Mean dependent variable" )		                                                                       ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
	b(%9.3f) se(%9.3f) r2(%9.3f)  nonotes                                                                                                 ///
	nogaps title(Reduced Form. \label{tab:rf})
	
***************************************************************************************************
****         Tab 5. Placebo			                                    			           ****
***************************************************************************************************	
estimates clear
eststo: xi:  reg ww1_vol_pop10       iAGRI_T62 $control_ww1 if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID62)
		qui: sum ww1_vol_pop10            if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40       iAGRI_T62 $control     if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID62)
		qui: sum ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww1_awards_pop10_is iAGRI_T62 $control_ww1 if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID62)
		qui: sum ww1_awards_pop10_is    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is iAGRI_T62 $control     if sample_ols == 1 & servicecommand != 7, cluster(DISTRICT_ID62)
		qui: sum ww2_awards_pop40_is    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab5_placebo.tex" ,	                                                                               ///
    indicate("WWI controls = *$control_ww1_nofe*" "WWII controls = *$control_nofe*" "State FE (48) = *state*")                   	   ///
	drop(_cons)                                                                                                                    ///
	mgroups("Volunteers" "Medals" , pattern(1 0 1 0)                                                                               ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
			span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
	mlabel("WWI" "WWII" "WWI" "WWII")            			                                                                       ///
	scalars("y_mean_round Mean dependent variable" )                                                                               ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
	b(%9.3f) se(%9.3f) r2(%9.3f)                                                                                                   ///
	nogaps title(Pre-WWI Committee Membership. \label{tab:placebo}) nonotes
	
***************************************************************************************************
****         Tab 6.  Mediation			                                    			       ****
****                 Panel A: New Deal grants                                			       ****
***************************************************************************************************	
foreach mediator in c40emp c40wage FDR40 {
	cap drop state1-state39
	tab stateicpsr if sample_ols == 1 , gen(state)
	macro def controlmediation     "ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC state1-state48"
	sgmediation iwarbond_1944_PC if sample_ols == 1 , mv(`mediator') iv(iNDEXP_PC) cv($controlmediation) 
	local bond_`mediator'      = string(`r(ind2tot)'*100, "%9.1f") + "%"

	drop state1-state48
	tab stateicpsr if sample_ols == 1 & servicecommand != 7, gen(state)
	macro def controlmediation     "ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC state1-state39"
	sgmediation ww2_vol_pop40        if sample_ols == 1 & servicecommand != 7, mv( `mediator') iv(iNDEXP_PC) cv($controlmediation) 
	local volunteer_`mediator' = string(`r(ind2tot)'*100, "%9.1f") + "%"
	sgmediation ww2_awards_pop40_is  if sample_ols == 1 & servicecommand != 7, mv( `mediator') iv(iNDEXP_PC) cv($controlmediation) 
	local medal_`mediator'     = string(`r(ind2tot)'*100, "%9.1f") + "%"
	sgmediation pc1                  if sample_ols == 1 & servicecommand != 7, mv( `mediator') iv(iNDEXP_PC) cv($controlmediation) 
	local pca_`mediator'       = string(`r(ind2tot)'*100, "%9.1f") + "%"
} /* foreach mediator */

preserve
	clear
	set obs 3
	gen     mediator  = "1940 employment"     if _n == 1
	replace mediator  = "1939 wage"           if _n == 2
	replace mediator  = "1940 FDR vote share" if _n == 3
	gen bond      = ""
	gen volunteer = ""
	gen medal     = ""
	gen pca       = ""
	lab var mediator "Mediation variable" 
	lab var bond "War bonds" 
	lab var volunteer "Volunteers"
	lab var medal "Medals"
	lab var pca "PCA"
	local i 0
	foreach mediator in c40emp c40wage FDR40 {
		local i = `i' + 1
		foreach outcome in bond volunteer medal pca {
			replace `outcome' = "``outcome'_`mediator''" if _n == `i'
		} /* foreach mediator */
	} /* foreach mediator */
	texsave using "results/tables/AppTab6A_mediation_tot_grants.tex", replace frag varlab
restore

***************************************************************************************************	
****                 Panel B: Agricultural grants                            			       ****
***************************************************************************************************	
use "tmp/patriot", clear 
foreach mediator in c40emp c40wage FDR40 {
	cap drop state1-state39
	tab stateicpsr if sample_ols == 1 , gen(state)
	macro def controlmediation     "ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC state1-state48"
	sgmediation iwarbond_1944_PC if sample_ols == 1 , mv(`mediator') iv(iAGRI_PF) cv($controlmediation) 
	local bond_`mediator'      = string(`r(ind2tot)'*100, "%9.1f") + "%"

	drop state1-state48
	tab stateicpsr if sample_ols == 1 & servicecommand != 7, gen(state)
	macro def controlmediation     "ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet lc40wage iwarconpro_PC state1-state39"
	sgmediation ww2_vol_pop40        if sample_ols == 1 & servicecommand != 7, mv( `mediator') iv(iAGRI_PF) cv($controlmediation) 
	local volunteer_`mediator' = string(`r(ind2tot)'*100, "%9.1f") + "%"
	sgmediation ww2_awards_pop40_is  if sample_ols == 1 & servicecommand != 7, mv( `mediator') iv(iAGRI_PF) cv($controlmediation) 
	local medal_`mediator'     = string(`r(ind2tot)'*100, "%9.1f") + "%"
	sgmediation pc1                  if sample_ols == 1 & servicecommand != 7, mv( `mediator') iv(iAGRI_PF) cv($controlmediation) 
	local pca_`mediator'       = string(`r(ind2tot)'*100, "%9.1f") + "%"
} /* foreach mediator */

preserve
	clear
	set obs 3
	gen     mediator  = "1940 employment"     if _n == 1
	replace mediator  = "1939 wage"           if _n == 2
	replace mediator  = "1940 FDR vote share" if _n == 3
	gen bond      = ""
	gen volunteer = ""
	gen medal     = ""
	gen pca       = ""
	lab var mediator "Mediation variable" 
	lab var bond "War bonds" 
	lab var volunteer "Volunteers"
	lab var medal "Medals"
	lab var pca "PCA"
	local i 0
	foreach mediator in c40emp c40wage FDR40 {
		local i = `i' + 1
		foreach outcome in bond volunteer medal pca {
			replace `outcome' = "``outcome'_`mediator''" if _n == `i'
		} /* foreach mediator */
	} /* foreach mediator */
	texsave using "results/tables/AppTab6B_mediation_agri_support", replace frag varlab
restore

***************************************************************************************************	
****         Tab 8.  Panel Regressions                                			               ****
***************************************************************************************************	
preserve
	use "data/patriotism-panel", replace
	lab var iNDEXP_PC_post      "New Deal grants $\times$ Post New Deal"
	lab var iNDEXP_PCx			"New Deal grants"
	lab var iAGRI_PF_post       "Agricultural support $\times$ Post New Deal"
	lab var iAGRI_PFx 			"Agricultural support"
	lab var iSUM3MO_DROUGHT_ww2 "Months of drought: pre WW II"
	lab var iAGRI_ww2 			"Tenure Agri committee: pre WW II"
	lab var iSUM3MO_DROUGHT_ww1 "Months of drought: pre WW I"
	lab var iAGRI_ww1			"Tenure Agri committee: pre WW I"
	
	estimates clear
	eststo: xi: reg vol_pop       iNDEXP_PC_post iNDEXP_PCx                                                         $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum vol_pop       if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi: reg awards_pop_is iNDEXP_PC_post iNDEXP_PCx                                                         $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum awards_pop_is if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")

	eststo: xi: reg vol_pop       iAGRI_PF_post   iAGRI_PFx                                                         $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum vol_pop       if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi: reg awards_pop_is iAGRI_PF_post   iAGRI_PFx                                                         $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum awards_pop_is if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")

	eststo: xi: reg vol_pop                            iSUM3MO_DROUGHT_ww2 iAGRI_ww2  iSUM3MO_DROUGHT_ww1 iAGRI_ww1 $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum vol_pop       if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi: reg awards_pop_is                      iSUM3MO_DROUGHT_ww2 iAGRI_ww2  iSUM3MO_DROUGHT_ww1 iAGRI_ww1 $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum awards_pop_is if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")

	eststo: xi:   ivreg  vol_pop       (iAGRI_PF_post = iSUM3MO_DROUGHT_ww2 iAGRI_ww2) iSUM3MO_DROUGHT_ww1 iAGRI_ww1 $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum vol_pop       if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:   ivreg  awards_pop_is (iAGRI_PF_post = iSUM3MO_DROUGHT_ww2 iAGRI_ww2) iSUM3MO_DROUGHT_ww1 iAGRI_ww1 $panelcontrols i.stateicpsr i.time , cluster(panel)
		   qui: sum awards_pop_is if e(sample) == 1 & time == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")

	esttab using "results/tables/AppTab8_tab-panel.tex" ,	                                                                             ///
		indicate("County controls = $panelcontrols" "War FEs = *time*" "State FEs = *state*" )                   		             ///
		order(iNDEXP_PC_post iNDEXP_PCx iAGRI_PF_post iAGRI_PFx iSUM3MO_DROUGHT_ww2 iAGRI_ww2 iSUM3MO_DROUGHT_ww1 iAGRI_ww1)         ///
		drop(_cons)                                                                                                                  ///
		mgroups("Volunteers" "Medals" "Volunteers" "Medals" "Volunteers" "Medals" "Volunteers" "Medals", pattern(1 1 1 1 1 1 1 1 )   ///
				prefix(\multicolumn{@span}{c}{) suffix(})                                                                            ///
				span erepeat(\cmidrule(lr){@span}) )			                                                                     ///
		mlabel("OLS" "OLS" "OLS" "OLS" "RF" "RF" "2SLS" "2SLS")                                                                      ///
		scalars("y_mean_round Mean dependent variable" )		                                                                     ///
		replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                 ///
		b(%9.3f) se(%9.3f) r2(%9.3f) nonotes                                                                                                ///
		nogaps title(New Deal Support and Patriotism: Panel Regressions\label{tab:panel}.)
restore
		
***************************************************************************************************
****         Tab 9.  Frontier experience			                                    	   ****
***************************************************************************************************	
estimates clear
eststo: xi:  reg iwarbond_1944_PC    iAGRI_PF   tye_tfe890_500k_100_l6 $control if sample_ols == 1                      , r
		qui: sum iwarbond_1944_PC    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40       iAGRI_PF   tye_tfe890_500k_100_l6 $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum ww2_vol_pop40       if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is iAGRI_PF   tye_tfe890_500k_100_l6 $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum ww2_awards_pop40_is if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg pc1                 iAGRI_PF   tye_tfe890_500k_100_l6 $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum pc1                 if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi:  ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) tye_tfe890_500k_100_l6 $control if sample_ols == 1                         , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  iwarbond_1944_PC   if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) tye_tfe890_500k_100_l6 $control if sample_ols == 1  & servicecommand   != 7, cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  ww2_vol_pop40      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) tye_tfe890_500k_100_l6 $control if sample_ols == 1 & servicecommand   != 7 , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  ww2_awards_pop40_is if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) tye_tfe890_500k_100_l6 $control if sample_ols == 1 & servicecommand   != 7 , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  pc1                 if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab9_robust-frontier.tex" ,	                                                                       ///
	order(iAGRI_PF  tye_tfe890_500k_100_l6) drop(_cons)                                                                            ///
	indicate("State FE (48) = *state*")                   		                                                                   ///
	mgroups("OLS"  "2SLS", pattern(1 0 0 0 1 0 0 0)           		                                                               ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
			span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
	mlabel("War bonds" "Volunteers" "Medals" "PCA" "War bonds" "Volunteers" "Medals" "PCA")                                        ///
	scalars("y_mean_round Mean dependent variable" "RA_test Rubin-Anderson test (p-value)")  	                                   ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
	b(%9.3f) se(%9.3f) r2(%9.3f)                                                                                                    ///
	nogaps title("Robust: Regressions Controlling for Frontier Experience.\label{tab:frontier}") nonotes

***************************************************************************************************
****         Tab 10. Women volunteers			                                    		   ****
***************************************************************************************************
estimates clear
eststo: xi: reg ww2_volw_pop40    iNDEXP_PC                                  $control  if sample_ols == 1 & servicecommand != 7, r 
	   qui: sum ww2_volw_pop40    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi: reg ww2_volw_pop40    iAGRI_PF                                   $control  if sample_ols == 1 & servicecommand != 7, r 
	   qui: sum ww2_volw_pop40    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi: reg ww2_volw_pop40               iSUM3MO_DROUGHT3340 iAGRI_T73   $control  if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) 
	   qui: sum ww2_volw_pop40    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi: ivreg2 ww2_volw_pop40 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control  if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) 
	   qui: sum ww2_volw_pop40    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab10_women-volunteers.tex" ,	                                     ///
    indicate("County-level controls = $control_nofe" "State FEs = *state*" )                   		 ///
	order(iNDEXP_PC iAGRI_PF iSUM3MO_DROUGHT3340 iAGRI_T73)                                          ///
	drop(_cons)                                                                                      ///
	mgroups("Women volunteers", pattern(1 0 0 0)                                                     ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                ///
			span erepeat(\cmidrule(lr){@span}) )			                                         ///
	mlabel("OLS" "OLS" "RF" "2SLS")                                                                  ///
	scalars("y_mean_round Mean dependent variable" )		                                         ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	     ///
	b(%9.3f) se(%9.3f) r2(%9.3f) nonotes                                                                     ///
	nogaps title(Effect of New Deal and Agricultural Support on Women Volunteer per Capita.\label{tab:women-volunteers})


***************************************************************************************************	
****         Tab 11. Spatial Autocorrelation                                                   ****
****                 Panel A: Moran's I                                      			       ****
***************************************************************************************************	
xi:  reg iwarbond_1944_PC    iAGRI_PF  $control if sample_ols == 1                      , r
	predict e_ols1 if e(sample) == 1, resid
xi:  reg ww2_vol_pop40       iAGRI_PF  $control if sample_ols == 1 & servicecommand != 7, r
	predict e_ols2 if e(sample) == 1, resid
xi:  reg ww2_awards_pop40_is iAGRI_PF  $control if sample_ols == 1 & servicecommand != 7, r
	predict e_ols3 if e(sample) == 1, resid
xi:  reg pc1                 iAGRI_PF  $control if sample_ols == 1 & servicecommand != 7, r
	predict e_ols4 if e(sample) == 1, resid
	
xi:  ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1                      , cluster(CLIMDIVX) 
	predict e_iv1  if e(sample) == 1, resid
xi:  ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
	predict e_iv2  if e(sample) == 1, resid 
xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
	predict e_iv3  if e(sample) == 1, resid
xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73 ) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
	predict e_iv4  if e(sample) == 1, resid
	
for VAR in any ols1 ols2 ols3 ols4 iv1 iv2 iv3 iv4: gen s_VAR = e_VAR * iAGRI_PF

foreach cut in 200 400 600 800  1000 { 	
	moransi e_ols1, lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_ols1 = r(pI)
	moransi e_ols2, lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_ols2 = r(pI)
	moransi e_ols3, lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_ols3 = r(pI)
	moransi e_ols4, lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_ols4 = r(pI)
	moransi e_iv1 , lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_iv1  = r(pI)
	moransi e_iv2 , lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_iv2  = r(pI)
	moransi e_iv3 , lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_iv3  = r(pI)
	moransi e_iv4 , lon(lonx_nd) lat(latx_nd) swm(bin) dist(`cut') dunit(km) approx detail
		local moran_iv4  = r(pI)
		
	preserve
		clear
		set obs 1
		gen Bandwidth = "`cut' km"

		foreach var in ols1 ols2 ols3 ols4 iv1 iv2 iv3 iv4 {
			gen moran_`var' = `moran_`var''/2
			format moran_`var' %9.4f
		} /* foreach var */

		save "tmp/moransi_`cut'", replace
	restore
} /* foreach cut */

preserve
	clear
	foreach cut in 200 400 600 800 1000 { 	
		append using "tmp/moransi_`cut'"
	} /* foreach cut */
	lab var Bandwidth  "Bandwidth"
	lab var moran_ols1 "Warbonds"
	lab var moran_ols2 "Volunteers"
	lab var moran_ols3 "Medals"
	lab var moran_ols4 "PCA"
	lab var moran_iv1 "Warbonds"
	lab var moran_iv2 "Volunteers"
	lab var moran_iv3 "Medals"
	lab var moran_iv4 "PCA"

	replace moran_ols1 = round(moran_ols1, 0.0001)
	replace moran_ols2 = round(moran_ols2, 0.0001)
	replace moran_ols3 = round(moran_ols3, 0.0001)
	replace moran_ols4 = round(moran_ols4, 0.0001)

	replace moran_iv1 = round(moran_iv1, 0.0001)
	replace moran_iv2 = round(moran_iv2, 0.0001)
	replace moran_iv3 = round(moran_iv3, 0.0001)
	replace moran_iv4 = round(moran_iv4, 0.0001)

	format moran_* %9.4f

	tostring moran*, force replace
	
	foreach var in moran_ols1 moran_ols2 moran_ols3 moran_ols4 moran_iv1 moran_iv2 moran_iv3 moran_iv4{
		replace `var' = "1.0000" if `var' == "1"
		replace `var' = "0.0000" if `var' == "0"
		replace `var' = "0" + `var' if strpos(`var', ".") == 1 
		replace `var' = substr(`var',1,6)
	}
	texsave using "results/tables/AppTab11A_moran", replace frag varlab
restore

***************************************************************************************************	
****                 Panel B. Conley s.e.                                    			       ****
***************************************************************************************************	
estimates clear
eststo: xi:  reg   iwarbond_1944_PC     iAGRI_PF                                  $control if sample_ols == 1                      , r 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b11 = string(e(b)[1,1], "%9.3f")
local se11 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 11s = string(2*ttail(e(df_r),abs(`p')), "%9.3f")
local se11n = 2*ttail(e(df_r),abs(`p'))
if `se11n' < .01{
	local st11 = "$^{***}$"
}
if `se11n' < .05 & `se11n' > .01{
	local st11 = "$^{**}$"
}
if `se11n' < .1 & `se11n' > .05{
	local st11 = "$^{*}$"
}

local n11 =  string(e(N))

estimates clear
eststo: xi:  reg   ww2_vol_pop40        iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b12 = string(e(b)[1,1], "%9.3f")
local se12 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 12s = string(2*ttail(e(df_r),abs(`p')), "%9.3f")
local se12n = 2*ttail(e(df_r),abs(`p'))
if `se12n' < .01{
	local st12 = "$^{***}$"
}
if `se12n' < .05 & `se12n' > .01{
	local st12 = "$^{**}$"
}
if `se12n' < .1 & `se12n' > .05{
	local st12 = "$^{*}$"
}

local n12 = string(e(N))

estimates clear
eststo: xi:  reg   ww2_awards_pop40_is  iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b13 = string(e(b)[1,1], "%9.3f")
local se13 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 13s = string(2*ttail(e(df_r),abs(`p')), "%9.3f")
local se13n = 2*ttail(e(df_r),abs(`p'))
if `se13n' < .01{
	local st13 = "$^{***}$"
}
if `se13n' < .05 & `se13n' > .01{
	local st13 = "$^{**}$"
}
if `se13n' < .1 & `se13n' > .05{
	local st13 = "$^{*}$"
}

local n13 =  string(e(N))

estimates clear
eststo: xi:  reg   pc1				    iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b14 = string(e(b)[1,1], "%9.3f")
local se14 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 14s = string(2*ttail(e(df_r),abs(`p')), "%9.3f")
local se14n = 2*ttail(e(df_r),abs(`p'))
if `se14n' < .01{
	local st14 = "$^{***}$"
}
if `se14n' < .05 & `se14n' > .01{
	local st14 = "$^{**}$"
}
if `se14n' < .1 & `se14n' > .05{
	local st14 = "$^{*}$"
}

local n14 =  string(e(N))

estimates clear
eststo: xi: ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1                      , cluster(CLIMDIVX) 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b15 = string(e(b)[1,1], "%9.3f")
local se15 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 15s = string(2*ttail(e(Fdf2),abs(`p')), "%9.3f")
local se15n = 2*ttail(e(Fdf2),abs(`p'))
if `se15n' < .01{
	local st15 = "$^{***}$"
}
if `se15n' < .05 & `se15n' > .01{
	local st15 = "$^{**}$"
}
if `se15n' < .1 & `se15n' > .05{
	local st15 = "$^{*}$"
}

local n15 =  string(e(N))

estimates clear
eststo: xi: ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b16 = string(e(b)[1,1], "%9.3f")
local se16 = string(sqrt(e(V)[1,1]), "%9.3f")
local p = e(b)[1,1]/sqrt(e(V)[1,1])

local 16s = string(2*ttail(e(Fdf2),abs(`p')), "%9.3f")
local se16n = 2*ttail(e(Fdf2),abs(`p'))

if `se16n' < .01{
	local st16 = "$^{***}$"
}
if `se16n' < .05 & `se16n' > .01{
	local st16 = "$^{**}$"
}
if `se16n' < .1 & `se16n' > .05{
	local st16 = "$^{*}$"
}

local n16 = string(e(N))

estimates clear
eststo: xi: ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b17 = string(e(b)[1,1], "%9.3f")
local se17 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 17s = string(2*ttail(e(Fdf2),abs(`p')), "%9.3f")
local se17n = 2*ttail(e(Fdf2),abs(`p'))
if `se17n' < .01{
	local st17 = "$^{***}$"
}
if `se17n' < .05 & `se17n' > .01{
	local st17 = "$^{**}$"
}
if `se17n' < .1 & `se17n' > .05{
	local st17 = "$^{*}$"
}

local n17 = string(e(N))

estimates clear
eststo: xi: ivreg2 pc1				   (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) 

local ts = e(b)[1,1]/sqrt(e(V)[1,1])

local b18 = string(e(b)[1,1], "%9.3f")
local se18 = string(sqrt(e(V)[1,1]), "%9.3f")

local p = e(b)[1,1]/sqrt(e(V)[1,1])
local 18s = string(2*ttail(e(Fdf2),abs(`p')), "%9.3f")
local se18n = 2*ttail(e(Fdf2),abs(`p'))
if `se18n' < .01{
	local st18 = "$^{***}$"
}
if `se18n' < .05 & `se18n' > .01{
	local st18 = "$^{**}$"
}
if `se18n' < .1 & `se18n' > .05{
	local st18 = "$^{*}$"
}

local n18 = string(e(N))

preserve
drop if lat_nd == . | lon_nd == .
local cf 200 400 600 800
forvalues z = 1/4{
local r = `z'+2
local cutoff: word `z' of `cf' 
	estimates clear
	eststo: xi:  acreg iwarbond_1944_PC    iAGRI_PF                                   $control if sample_ols == 1                      , latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett

	local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'1 = "[`tmp1']" + "`tmp4'"
	
	estimates clear
	eststo: xi:  acreg ww2_vol_pop40       iAGRI_PF                                   $control if sample_ols == 1 & servicecommand != 7, latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett
	
	local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'2 = "[`tmp1']" + "`tmp4'"
	
	estimates clear
	eststo: xi:  acreg ww2_awards_pop40_is iAGRI_PF                                   $control if sample_ols == 1 & servicecommand != 7, latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett
		local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'3 = "[`tmp1']" + "`tmp4'"
	
	estimates clear
	eststo: xi:  acreg pc1				   iAGRI_PF                                   $control if sample_ols == 1 & servicecommand != 7, latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett
		local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'4 = "[`tmp1']" + "`tmp4'"
	
	estimates clear	
	eststo: xi:  acreg iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1                      , latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett 
		local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'5 = "[`tmp1']" + "`tmp4'"
	
	estimates clear
	eststo: xi:  acreg ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett 
		local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'6 = "[`tmp1']" + "`tmp4'"
	
	estimates clear
	eststo: xi:  acreg ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett 
	
		local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'7 = "[`tmp1']" + "`tmp4'"

	estimates clear
	eststo: xi:  acreg pc1				   (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, latitude(lat_nd) longitude(lon_nd)  dist( `cutoff' ) spatial bartlett 
		local tmp1 = string(sqrt(e(V)[1,1]), "%9.3f")
	
	local tmp2 = e(b)[1,1]/sqrt(e(V)[1,1])		
	local tmp3 = 2*ttail(e(Fdf2),abs(`tmp2'))

	if `tmp3' < .01{
		local tmp4 = "$^{***}$"
	}
	if `tmp3' < .05 & `tmp3' > .01{
		local tmp4 = "$^{**}$"
	}
	if `tmp3' < .1 & `tmp3' > .05{
		local tmp4 = "$^{*}$"
	}
	
	local se`r'8 = "[`tmp1']" + "`tmp4'"
	} /* foreach cutoff */

restore


preserve
clear
set obs 10

gen bstab = ""
replace bstab in 1 = "Agricultural support"
replace bstab in 2 = "Baseline s.e."
replace bstab in 3 = "Conley (1999) s.e.: cutoff = 200 km"
replace bstab in 4 = "Conley (1999) s.e.: cutoff = 400 km"
replace bstab in 5 = "Conley (1999) s.e.: cutoff = 600 km"
replace bstab in 6 = "Conley (1999) s.e.: cutoff = 800 km"

replace bstab in 8 = "Controls"
replace bstab in 9 = "State FE(48)"
replace bstab in 10 = "Observation"

lab var bstab ""

gen warbond1 = ""
replace warbond1 in 1 = "`b11'"
replace warbond1 in 2 = "[`se11']" + "`st11'"
replace warbond1 in 3 = "`se31'"
replace warbond1 in 4 = "`se41'"
replace warbond1 in 5 = "`se51'"
replace warbond1 in 6 = "`se61'"

replace warbond1 in 8 = "Yes"
replace warbond1 in 9 = "Yes"
replace warbond1 in 10 = "`n11'"
lab var warbond1 "Warbonds"

gen volunteers1 = ""
replace volunteers1 in 1 = "`b12'"
replace volunteers1 in 2 = "[`se12']" + "`st12'"
replace volunteers1 in 3 = "`se32'"
replace volunteers1 in 4 = "`se42'"
replace volunteers1 in 5 = "`se52'"
replace volunteers1 in 6 = "`se62'"

replace volunteers1 in 8 = "Yes"
replace volunteers1 in 9 = "Yes"
replace volunteers1 in 10 = "`n12'"
lab var volunteers1 "Volunteers"

gen medals1 = ""
replace medals1 in 1 = "`b13'"
replace medals1 in 2 = "[`se13']" + "`st13'"
replace medals1 in 3 = "`se33'"
replace medals1 in 4 = "`se43'"
replace medals1 in 5 = "`se53'"
replace medals1 in 6 = "`se63'"

replace medals1 in 8 = "Yes"
replace medals1 in 9 = "Yes"
replace medals1 in 10 = "`n13'"
lab var medals1 "Medals"

gen pca1 = ""
replace pca1 in 1 = "`b14'"
replace pca1 in 2 = "[`se14']" + "`st14'"
replace pca1 in 3 = "`se34'"
replace pca1 in 4 = "`se44'"
replace pca1 in 5 = "`se54'"
replace pca1 in 6 = "`se64'"

replace pca1 in 8 = "Yes"
replace pca1 in 9 = "Yes"
replace pca1 in 10 = "`n14'"
lab var pca1 "Medals"

gen warbond2 = ""
replace warbond2 in 1 = "`b15'"
replace warbond2 in 2 = "[`se15']" + "`st15'"
replace warbond2 in 3 = "`se35'"
replace warbond2 in 4 = "`se45'"
replace warbond2 in 5 = "`se55'"
replace warbond2 in 6 = "`se65'"

replace warbond2 in 8 = "Yes"
replace warbond2 in 9 = "Yes"
replace warbond2 in 10 = "`n15'"
lab var warbond2 "Warbonds"

gen volunteers2 = ""
replace volunteers2 in 1 = "`b16'"
replace volunteers2 in 2 = "[`se16']" + "`st16'"
replace volunteers2 in 3 = "`se36'"
replace volunteers2 in 4 = "`se46'"
replace volunteers2 in 5 = "`se56'"
replace volunteers2 in 6 = "`se66'"

replace volunteers2 in 8 = "Yes"
replace volunteers2 in 9 = "Yes"
replace volunteers2 in 10 = "`n16'"
lab var volunteers2 "Volunteers"

gen medals2 = ""
replace medals2 in 1 = "`b17'"
replace medals2 in 2 = "[`se17']" + "`st17'"
replace medals2 in 3 = "`se37'"
replace medals2 in 4 = "`se47'"
replace medals2 in 5 = "`se57'"
replace medals2 in 6 = "`se67'"

replace medals2 in 8 = "Yes"
replace medals2 in 9 = "Yes"
replace medals2 in 10 = "`n17'"
lab var medals2 "Medals"

gen pca2 = ""
replace pca2 in 1 = "`b18'"
replace pca2 in 2 = "[`se18']" + "`st18'"
replace pca2 in 3 = "`se38'"
replace pca2 in 4 = "`se48'"
replace pca2 in 5 = "`se58'"
replace pca2 in 6 = "`se68'"

replace pca2 in 8 = "Yes"
replace pca2 in 9 = "Yes"
replace pca2 in 10 = "`n18'"
lab var pca2 "PCA"

texsave using "results/tables/AppTab11B_conley", replace varlab nofix frag
restore


***************************************************************************************************	
****         Tab 12. Entropy Balancing                                                         ****
***************************************************************************************************	

xtile  iNDEXP_PCm = iNDEXP_PC, n(2)
recode iNDEXP_PCm (1 = 0) (2 = 1)

ebalance iNDEXP_PCm ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 ///
	c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet	 ///
	lc40wage iwarconpro_PC if sample_ols == 1, gen(wiNDEXP_PC)
	
	
local vss iNDEXP_PCm ww1_vol_sh ww1_awards_pop10_is lpop30 c30unemp c30urban1 c30farm iYf_T29 MEAN9628 c30men c30black c30jap c30deu c30ita c30vet 	lc40wage iwarconpro_PC
	local v2 = 0
forvalues i=1/16{
	local v2 = `v2' + 1
	local bbt_`v2' = string(e(preBal)[`i', 1], "%9.3f")
	local bbc_`v2' = string(e(preBal)[`i', 4], "%9.3f")
	local abt_`v2' = string(e(postBal)[`i', 1], "%9.3f")
	local abc_`v2' = string(e(postBal)[`i', 4], "%9.3f")
	local v2 = `v2' + 1
	local bbt_`v2' = "("+string(sqrt(e(preBal)[`i', 2]), "%9.3f")+")"
	local bbc_`v2' = "("+string(sqrt(e(preBal)[`i', 5]), "%9.3f")+")"
	local abt_`v2' = "("+string(sqrt(e(postBal)[`i', 2]), "%9.3f")+")"
	local abc_`v2' = "("+string(sqrt(e(postBal)[`i', 5]), "%9.3f")+")"
}

preserve

clear
set obs 32
gen vars = ""
replace vars in 1 = "WWI volunteering rate"
replace vars in 3 = "WW1 awards per capita (i.h.s.)"
replace vars in 5 = "log 1930 population"
replace vars in 7 = "1930 unemployment rate"
replace vars in 9 = "1930 urban status dummy"
replace vars in 11 = "1930 farm share"
replace vars in 13 = "1929 farm income (i.h.s.)"
replace vars in 15 = "Mean Democratic vote share: 1898-1928"
replace vars in 17 = "1930 share of men"
replace vars in 19 = "1930 share of blacks"
replace vars in 21 = "1930 share of Japanese"
replace vars in 23 = "1930 share of Germans"
replace vars in 25 = "1930 share of Italians"
replace vars in 27 = "1930 share of veterans"
replace vars in 29 = "log 1939 average wage"
replace vars in 31 = "War contracts per capita (i.h.s.)"

gen bbt = ""
lab var bbt "Treated"

gen bbc = ""
lab var bbc "Control"	
gen abt = ""
lab var abt "Treated"
gen abc = ""
lab var abc "Control"	
forvalues m=1/32{
	replace bbt in `m' = "`bbt_`m''"
	replace bbc in `m' = "`bbc_`m''"
	replace abt in `m' = "`abt_`m''"
	replace abc in `m' = "`abc_`m''"
}

drop in 1/2

texsave using "results/tables/AppTab12_entropy", frag nofix replace varlab headerlines("& \multicolumn{2}{c}{Before balancing} & \multicolumn{2}{c}{After balancing} \\ \cmidrule(lr){2-3} \cmidrule(lr){4-5} \addlinespace[-2ex]") title("Entropy Balancing.}\label{tab:entropy") footnote("\noindent \textit{Notes:} Difference in covariates in counties above and below  median New Deal grants per capita (i.h.s.). Columns 1--2: averages before re-weighting. Columns 3--4: average after re-weighting with the formula of \citet{hainmueller2012entropy}")
restore

***************************************************************************************************	
****         Tab 13-15. Robustness in subsamples                                               ****
***************************************************************************************************	
foreach sample in sharecropper migration dust {
	if "`sample'" == "sharecropper" local if    "& lowsharec == 1"
	if "`sample'" == "sharecropper" local title "Bottom 33\% Counties in Share of Farms Operated by Owner"
	if "`sample'" == "sharecropper" local tab   "13"
	if "`sample'" == "sharecropper" local label "sharecropper"

	if "`sample'" == "dust"         local if "& dust_bowl != 1"
	if "`sample'" == "dust"         local title "Dust Bowl Counties"
	if "`sample'" == "dust"         local tab   "14"
	if "`sample'" == "dust"   	    local label "dustbowl"
	
	if "`sample'" == "migration"    local if    "& lowdpop   == 1"
	if "`sample'" == "migration"    local title "Top and Bottom 5\% Counties in 1930-40 Population Change"
	if "`sample'" == "migration"    local tab   "15"
	if "`sample'" == "migration"    local label "migrate"

	
	estimates clear
	eststo: xi:  reg iwarbond_1944_PC   iAGRI_PF    $control if sample_ols == 1 `if'                      , r
			qui: sum iwarbond_1944_PC      if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:  reg ww2_vol_pop40      iAGRI_PF    $control if sample_ols == 1 `if' & servicecommand != 7, r
			qui: sum ww2_vol_pop40         if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:  reg ww2_awards_pop40_is iAGRI_PF    $control if sample_ols == 1 `if' & servicecommand != 7, r
			qui: sum ww2_awards_pop40_is    if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:  reg pc1                 iAGRI_PF    $control if sample_ols == 1 `if' & servicecommand != 7, r
			qui: sum pc1                    if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")

	eststo: xi:  ivreg2 iwarbond_1944_PC  (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73)  $control if sample_ols == 1 `if'                        , cluster(CLIMDIVX) first
	estadd local RA_test = string(`e(arfp)', "%4.3f")
			qui:   sum  iwarbond_1944_PC   if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:  ivreg2 ww2_vol_pop40     (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73)  $control if sample_ols == 1 `if'   & servicecommand != 7, cluster(CLIMDIVX) first
	estadd local RA_test = string(`e(arfp)', "%4.3f")
			qui:   sum  ww2_vol_pop40      if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73)  $control if sample_ols == 1 `if' & servicecommand != 7, cluster(CLIMDIVX) first
	estadd local RA_test = string(`e(arfp)', "%4.3f")
			qui:   sum  ww2_awards_pop40_is if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")
	eststo: xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73)  $control if sample_ols == 1 `if' & servicecommand != 7, cluster(CLIMDIVX) first
	estadd local RA_test = string(`e(arfp)', "%4.3f")
			qui:   sum  pc1                 if e(sample) == 1
	estadd local y_mean_round = string(r(mean), "%9.3f")

	esttab using "results/tables/AppTab`tab'_robust-`sample'.tex" ,	                                                           ///
	indicate("State FE (48) = *state*")                   		                                                                       ///
		order(iAGRI_PF ) drop(_cons)                                                                                                   ///
		mgroups("OLS"  "2SLS", pattern(1 0 0 0 1 0 0 0)           		                                                               ///
				prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
				span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
		mlabel("War bonds" "Volunteers" "Medals" "PCA" "War bonds" "Volunteers" "Medals" "PCA")                                        ///
		scalars("y_mean_round Mean dependent variable" "RA_test Rubin-Anderson test (p-value)")                                        ///
		replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
		b(%9.3f) se(%9.3f) r2(%9.3f)                                                                                                   ///
		nogaps title(Robust: Regressions Without `title'. \label{tab:`label'}) nonotes
} /* foreach sample */

***************************************************************************************************
****         Tab 16. Inverse of 1930 population                                      		   ****
***************************************************************************************************	
estimates clear
eststo: xi:  reg iwarbond_1944_PC    iAGRI_PF   invpop_w99 $control if sample_ols == 1                      , r
		qui: sum iwarbond_1944_PC    if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_vol_pop40       iAGRI_PF   invpop_w99 $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum ww2_vol_pop40       if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg ww2_awards_pop40_is iAGRI_PF   invpop_w99 $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum ww2_awards_pop40_is if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  reg pc1                 iAGRI_PF   invpop_w99 $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum pc1                 if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

eststo: xi:  ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) invpop_w99 $control if sample_ols == 1                         , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  iwarbond_1944_PC   if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) invpop_w99 $control if sample_ols == 1  & servicecommand   != 7, cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  ww2_vol_pop40      if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) invpop_w99 $control if sample_ols == 1 & servicecommand   != 7 , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  ww2_awards_pop40_is if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
eststo: xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) invpop_w99 $control if sample_ols == 1 & servicecommand   != 7 , cluster(CLIMDIVX) first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui:   sum  pc1                 if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")

esttab using "results/tables/AppTab16_robust-invpop.tex" ,	                                                                       ///
	order(iAGRI_PF  invpop_w99) drop(_cons)                                                                                        ///
	indicate("State FE (48) = *state*")                   		                                                                   ///
	mgroups("OLS"  "2SLS", pattern(1 0 0 0 1 0 0 0)           		                                                               ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                                                              ///
			span erepeat(\cmidrule(lr){@span}) )			                                                                       ///
	mlabel("War bonds" "Volunteers" "Medals" "PCA" "War bonds" "Volunteers" "Medals" "PCA")                                        ///
	scalars("y_mean_round Mean dependent variable" "RA_test Rubin-Anderson test (p-value)")  	                                   ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01) obslast nomtitles  compress longtable 	                                   ///
	b(%9.3f) se(%9.3f) r2(%9.3f)                                                                                                   ///
	nogaps title("Robust: Regressions Controlling for Inverse of 1930 Population.\label{tab:invpop}") nonotes


***************************************************************************************************
****         Tab 17. The Impact of Service Comamnd 7                                 		   ****
***************************************************************************************************	
estimates clear
eststo: xi:  reg   iwarbond_1944_PC   iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r
		qui: sum   iwarbond_1944_PC           if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "No"
eststo: xi:   reg  iwarbond_1944_PC              iSUM3MO_DROUGHT3340 iAGRI_T73  $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX) 
		qui: sum   iwarbond_1944_PC           if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "No"
eststo: xi: ivreg2 iwarbond_1944_PC   (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)  first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui: sum   iwarbond_1944_PC           if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "No"

eststo: xi:  reg   ww2_vol_pop40 iAGRI_PF                                        $control if sample_ols == 1, r
		qui: sum   ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "Yes"
eststo: xi:   reg  ww2_vol_pop40                 iSUM3MO_DROUGHT3340 iAGRI_T73  $control if sample_ols == 1, cluster(CLIMDIVX) 
		qui: sum   ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "Yes"
eststo: xi: ivreg2 ww2_vol_pop40      (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1, cluster(CLIMDIVX)  first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui: sum   ww2_vol_pop40         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "Yes"

eststo: xi:  reg   ww2_awards_pop40_is iAGRI_PF                                        $control if sample_ols == 1, r
		qui: sum   ww2_awards_pop40_is         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "Yes"
eststo: xi:   reg  ww2_awards_pop40_is                 iSUM3MO_DROUGHT3340 iAGRI_T73  $control if sample_ols == 1, cluster(CLIMDIVX) 
		qui: sum   ww2_awards_pop40_is         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "Yes"
eststo: xi: ivreg2 ww2_awards_pop40_is      (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1, cluster(CLIMDIVX)  first
estadd local RA_test = string(`e(arfp)', "%4.3f")
		qui: sum   ww2_awards_pop40_is         if e(sample) == 1
estadd local y_mean_round = string(r(mean), "%9.3f")
estadd local sample "Yes"

esttab using "results/tables/AppTab17_service_command7.tex" ,                             ///
	order(iAGRI_PF iSUM3MO_DROUGHT3340 iAGRI_T73)                                      ///
	drop(_cons)                                                                        ///
	indicate("County-level controls = $control_nofe" "State FE (48) = *state*")        ///
	mgroups("log war bonds p.c." "Volunteers p.c." "Medals p.c.", pattern(1 0 0 1 0 0 1 0 0)     ///
			prefix(\multicolumn{@span}{c}{) suffix(})                                  ///
			span erepeat(\cmidrule(lr){@span}))                                        ///
	mlabel("OLS" "RF" "2SLS" "OLS" "RF" "2SLS" "OLS" "RF" "2SLS")                      ///
	replace br se  label star(* 0.10 ** 0.05 *** 0.01)                                 ///
	obslast nomtitles  compress longtable 	                                           ///
	title(Robust: The Impact of Service Command 7.\label{tab:sc7})                     ///
	b(%9.3f) se(%9.3f) r2(%9.3f)                                                       ///
	nogaps nonotes                                                                     ///
	scalars("sample Sample includes S.C. \#7?" "y_mean_round Mean dependent variable" "RA_test Rubin-Anderson test (p-value)" )


***************************************************************************************************
****     II. Figures                                                                           ****
****         Fig 1. Heterogeneity by cattle ranching                                		   ****
***************************************************************************************************
estimates clear 
local n 0
local dependents iwarbond_1944_PC ww2_vol_pop40 ww2_awards_pop40_is pc1

foreach dependent of local dependents {
	if "`dependent'" == "iwarbond_1944_PC"    local cond
	if "`dependent'" == "iwarbond_1944_PC"    local splits = "median_above1==1 median_below1==1"
	if "`dependent'" == "ww2_vol_pop40"       local cond              "& servicecommand != 7"
	if "`dependent'" == "ww2_vol_pop40"   	  local splits = "median_above2==1 median_below2==1"
	if "`dependent'" == "ww2_awards_pop40_is" local cond              "& servicecommand != 7"
	if "`dependent'" == "ww2_awards_pop40_is" local splits = "median_above2==1 median_below2==1"
	if "`dependent'" == "pc1" 				  local cond              "& servicecommand != 7"
	if "`dependent'" == "pc1"    			  local splits = "median_above2==1 median_below2==1"

	foreach sample of local splits {
		local n = `n' + 1
		xi: reg `dependent' iAGRI_PF $control if sample_ols == 1 `cond' & `sample', r
		local b`n' =  _b[iAGRI_PF]
		local s`n' = _se[iAGRI_PF]
	} /* foreach sample */
} /* foreach dependent */

preserve
	clear
	set obs 8
	gen     x     = cond(mod(_n,2) == 1,_n,(_n-1)+0.4)  /* Odds are plotted at integer; evens are plotted at integer + 0.4 */
	gen     split = cond(mod(_n,2) == 1, 0,         1)  /* Odds are below median; evens are above median */
	gen b         = .
	gen s         = .
	forvalues n = 1(1)8 {
		replace b = `b`n'' if _n == `n'
		replace s = `s`n'' if _n == `n'
	} /* forvalues n */
	gen l = b - (1.96 * s)
	gen u = b + (1.96 * s)

	format b* %2.1f

	gen t     = 0.43
	gen title = cond(_n == 2,"{bf:War bonds}",cond(_n == 4,"{bf:Volunteers}",cond(_n == 6,"{bf:Medals}",cond(_n == 8,"{bf:PCA}",""))))
	gen x_t  = cond(_n == 2,1.2,cond(_n == 4,3.2,cond(_n == 6,5.2,cond(_n == 8,7.2,x))))
	
	graph twoway (scatter b    x if split == 0,  mcolor(red   )                  msize(*1.5) msymbol(oh))	           		 ///
				 (scatter b    x if split == 1,  mlcolor(green) mfcolor(none)    msize(*1.5) msymbol(oh))              		 ///
				 (rcap    l u  x if split == 0,    color(red  )                  msize(large)    lwidth(   thick))         	 ///
				 (rcap    l u  x if split == 1,    color(green)                  msize(medlarge) lwidth(medthick))         	 ///
				 (scatter t    x_t, mlabel(title        ) mlabcolor(black) mlabp(0) m(i) mlabsize(*1.2)) 	               	 ///
				, legend(order(3 "High" 4 "Low") rows(1) title("{bf: Cattle ranching incidence:}",  size(medium))) 	         ///
				yline(0, lcolor(red)) xline(2.2, lcolor(black) lpattern(dash)) xline(4.2, lcolor(black) lpattern(dash)) 	 ///
				xline(6.2, lcolor(black) lpattern(dash)) ylabel(0(0.1)0.4, angle(0) labsize(medium) format(%2.1f)) 		     ///
				ytitle(OLS coefficient, size(normal)) xlabel(none) xtitle(" ") xscale(range(0.4 7.8)) graphregion(fcolor(white)) plotregion(fcolor(white)) scheme(s1manual)
									   
	graph export "results/figures/AppFig1-cattle.pdf", replace
restore

***************************************************************************************************
****         Fig 2. Never Takers                                                    		   ****
***************************************************************************************************
kdensity iSUM3MO_DROUGHT3340 if aaa == 0 & servicecommand != 7, lp(dash) lc(black) addplot(kdensity iSUM3MO_DROUGHT3340 if aaa == 1 & servicecommand != 7, lc(black) lp(solid)) legend(order(1 "< 5th pct" 2 "5th-100th pct") title(Agricultural support:)) title(A. Droughts by agricultural support, size(huge)) graphregion(color(white)) ytitle(" ") ylabel(, angle(0) format(%2.1f)) xtitle(Months of summer drought) note("")
graph export "results/figures/AppFig2A-never-takers-distrib-drought.pdf", as(pdf) replace

cibar iAGRI_T73 , over(aaa) graphopts(legend(order(1 "< 5th pct" 2 "5th-100th pct") title(Agricultural support:)) title(B. Agri committee by agri support, size(huge)) graphregion(color(white)) ytitle(" ") ylabel(, angle(0) format(%3.2f)) note(""))
graph export "results/figures/AppFig2B-never-takers-distrib-committee.pdf", as(pdf) replace

gen iSUM3MO_DROUGHT3340_aaa = iSUM3MO_DROUGHT3340 * aaa
for VAR in var iwarbond_1944_PC iSUM3MO_DROUGHT3340 aaa iSUM3MO_DROUGHT3340_aaa : egen VAR_Z = std(VAR) if sample_ols == 1
 
reg iwarbond_1944_PC_Z iSUM3MO_DROUGHT3340_Z  iSUM3MO_DROUGHT3340_aaa_Z aaa_Z if sample_ols == 1 , r nocons
local b1_lo =  _b[iSUM3MO_DROUGHT3340_Z]
local s1_lo = _se[iSUM3MO_DROUGHT3340_Z]
lincom _b[iSUM3MO_DROUGHT3340_Z] + _b[iSUM3MO_DROUGHT3340_aaa_Z]
local b1_hi = r(estimate)
local s1_hi = r(se)

drop *_Z
for VAR in var ww2_vol_pop40 ww2_awards_pop40 pc1 iSUM3MO_DROUGHT3340 aaa iSUM3MO_DROUGHT3340_aaa : egen VAR_Z = std(VAR) if sample_ols == 1 & servicecommand != 7

reg ww2_vol_pop40_Z iSUM3MO_DROUGHT3340_Z  iSUM3MO_DROUGHT3340_aaa_Z aaa_Z if sample_ols == 1 & servicecommand !=7, r nocons 
local b2_lo =  _b[iSUM3MO_DROUGHT3340_Z]
local s2_lo = _se[iSUM3MO_DROUGHT3340_Z]
lincom _b[iSUM3MO_DROUGHT3340_Z] + _b[iSUM3MO_DROUGHT3340_aaa_Z]
local b2_hi = r(estimate)
local s2_hi = r(se)

reg ww2_awards_pop40_Z iSUM3MO_DROUGHT3340_Z  iSUM3MO_DROUGHT3340_aaa_Z aaa_Z if sample_ols == 1 & servicecommand !=7, r nocons 
local b3_lo =  _b[iSUM3MO_DROUGHT3340_Z]
local s3_lo = _se[iSUM3MO_DROUGHT3340_Z]
lincom _b[iSUM3MO_DROUGHT3340_Z] + _b[iSUM3MO_DROUGHT3340_aaa_Z]
local b3_hi = r(estimate)
local s3_hi = r(se)

reg pc1_Z iSUM3MO_DROUGHT3340_Z  iSUM3MO_DROUGHT3340_aaa_Z aaa_Z if sample_ols == 1 & servicecommand !=7, r nocons
local b4_lo =  _b[iSUM3MO_DROUGHT3340_Z]
local s4_lo = _se[iSUM3MO_DROUGHT3340_Z]
lincom _b[iSUM3MO_DROUGHT3340_Z] + _b[iSUM3MO_DROUGHT3340_aaa_Z]
local b4_hi = r(estimate)
local s4_hi = r(se)

preserve
	clear
	set obs 8
	gen b = .
	gen s = .
	forvalues n = 1(1)4 {
		replace b = `b`n'_lo' if _n == `n'
		replace s = `s`n'_lo' if _n == `n'
	} /* forvalues n */
	forvalues n = 5(1)8 {
		local nn = `n' - 4
		replace b = `b`nn'_hi' if _n == `n'
		replace s = `s`nn'_hi' if _n == `n'
	} /* forvalues n */
	
	gen l =  b - (1.96 * s)
	gen u =  b + (1.96 * s)

	format b* %2.1f

	gen n = cond(_n == 1,0.95  , ///
	        cond(_n == 2,1     , ///
	        cond(_n == 3,1.05  , ///
	        cond(_n == 4,1.1   , ///
	        cond(_n == 5,1.95  , ///
	        cond(_n == 6,2     , ///
	        cond(_n == 7,2.05  , ///
	        cond(_n == 8,2.1,.))))))))
	
	graph twoway (scatter b    n if _n == 1 | _n == 5 ,  mcolor(khaki)   msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 1 | _n == 5,    color(khaki)   msize(large) lwidth(thick))                  ///
                 (scatter b    n if _n == 2 | _n == 6,  mcolor(blue)  msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 2 | _n == 6,    color(blue)  msize(large) lwidth(thick))         		 ///
                 (scatter b    n if _n == 3 | _n == 7,  mcolor(green) msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 3 | _n == 7,    color(green) msize(large) lwidth(thick))         		 ///
                 (scatter b    n if _n == 4 | _n == 8,  mcolor(black) msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 4 | _n == 8,    color(black) msize(large) lwidth(thick)) , graphregion(color(white)) legend(order(1 "War bonds" 3 "Volunteers" 5 "Medals" 7 "PCA" ) title(Dependent variable:) row(2)) xlabel(1 "No agri support" 2 "Agri support") xtitle("") ylabel(-0.2(0.2)0.4, angle(0) format(%2.1f)) title(C. Drought {&beta} coefficients, size(huge)) yline(0, lc(red))
	graph export "results/figures/AppFig2C-never-takers-drought.pdf", as(pdf) replace
restore

drop *_Z

gen iAGRI_T73_aaa = iAGRI_T73 * aaa
for VAR in var iwarbond_1944_PC iAGRI_T73 aaa iAGRI_T73_aaa : egen VAR_Z = std(VAR) if sample_ols == 1
 
reg iwarbond_1944_PC_Z iAGRI_T73_Z  iAGRI_T73_aaa_Z aaa_Z if sample_ols == 1 , r nocons
local b1_lo =  _b[iAGRI_T73_Z]
local s1_lo = _se[iAGRI_T73_Z]
lincom _b[iAGRI_T73_Z] + _b[iAGRI_T73_aaa_Z]
local b1_hi = r(estimate)
local s1_hi = r(se)

drop *_Z
for VAR in var ww2_vol_pop40 ww2_awards_pop40 pc1 iAGRI_T73 aaa iAGRI_T73_aaa : egen VAR_Z = std(VAR) if sample_ols == 1 & servicecommand != 7

reg ww2_vol_pop40_Z iAGRI_T73_Z  iAGRI_T73_aaa_Z aaa_Z if sample_ols == 1 & servicecommand !=7, r nocons 
local b2_lo =  _b[iAGRI_T73_Z]
local s2_lo = _se[iAGRI_T73_Z]
lincom _b[iAGRI_T73_Z] + _b[iAGRI_T73_aaa_Z]
local b2_hi = r(estimate)
local s2_hi = r(se)

reg ww2_awards_pop40_Z iAGRI_T73_Z  iAGRI_T73_aaa_Z aaa_Z if sample_ols == 1 & servicecommand !=7, r nocons 
local b3_lo =  _b[iAGRI_T73_Z]
local s3_lo = _se[iAGRI_T73_Z]
lincom _b[iAGRI_T73_Z] + _b[iAGRI_T73_aaa_Z]
local b3_hi = r(estimate)
local s3_hi = r(se)

reg pc1_Z iAGRI_T73_Z  iAGRI_T73_aaa_Z aaa_Z if sample_ols == 1 & servicecommand !=7, r nocons
local b4_lo =  _b[iAGRI_T73_Z]
local s4_lo = _se[iAGRI_T73_Z]
lincom _b[iAGRI_T73_Z] + _b[iAGRI_T73_aaa_Z]
local b4_hi = r(estimate)
local s4_hi = r(se)

preserve
	clear
	set obs 8
	gen b = .
	gen s = .
	forvalues n = 1(1)4 {
		replace b = `b`n'_lo' if _n == `n'
		replace s = `s`n'_lo' if _n == `n'
	} /* forvalues n */
	forvalues n = 5(1)8 {
		local nn = `n' - 4
		replace b = `b`nn'_hi' if _n == `n'
		replace s = `s`nn'_hi' if _n == `n'
	} /* forvalues n */
	
	gen l =  b - (1.96 * s)
	gen u =  b + (1.96 * s)

	format b* %2.1f

	gen n = cond(_n == 1,0.95  , ///
	        cond(_n == 2,1     , ///
	        cond(_n == 3,1.05  , ///
	        cond(_n == 4,1.1   , ///
	        cond(_n == 5,1.95  , ///
	        cond(_n == 6,2     , ///
	        cond(_n == 7,2.05  , ///
	        cond(_n == 8,2.1,.))))))))
	
	graph twoway (scatter b    n if _n == 1 | _n == 5 ,  mcolor(khaki)   msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 1 | _n == 5,    color(khaki)   msize(large) lwidth(thick))                  ///
                 (scatter b    n if _n == 2 | _n == 6,  mcolor(blue)  msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 2 | _n == 6,    color(blue)  msize(large) lwidth(thick))         		 ///
                 (scatter b    n if _n == 3 | _n == 7,  mcolor(green) msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 3 | _n == 7,    color(green) msize(large) lwidth(thick))         		 ///
                 (scatter b    n if _n == 4 | _n == 8,  mcolor(black) msize(*1.5) msymbol(oh))	           		 ///
				 (rcap    l u  n if _n == 4 | _n == 8,    color(black) msize(large) lwidth(thick)) , graphregion(color(white)) legend(order(1 "War bonds" 3 "Volunteers" 5 "Medals" 7 "PCA" ) title(Dependent variable:) row(2)) xlabel(1 "No agri support" 2 "Agri support") xtitle("") ylabel(, angle(0) format(%2.1f)) title(D. Committee {&beta} coefficients, size(huge)) yline(0, lc(red))
	graph export "results/figures/AppFig2D-never-takers-committee.pdf", as(pdf) replace
restore

***************************************************************************************************
****         Fig 3. Heterogeneity: economic conditions                              		   ****
***************************************************************************************************
xi: reg pc1 c.iNDEXP_PC##i.c40e_10  $control if sample_ols == 1 & servicecommand != 7, r
margins , dydx(iNDEXP_PC) at(c40e_10=(1(1)10)) post
marginsplot , yline(0, lcolor(red)) graphregion(color(white)) title(" ") xtitle(Decile of 1940 employment rate, size(large)) ytitle({&beta}: New Deal grants on patriotism (PCA)) ylab( , angle(0) format(%2.1f)) title("A. Employment and New Deal grants", size(huge))
graph export "results/figures/AppFig3A-margins-ndexp-e40.pdf", replace as(pdf)

xi: reg pc1 c.iAGRI_PF##i.c40e_10   $control if sample_ols == 1 & servicecommand != 7, r
margins , dydx(iAGRI_PF) at(c40e_10=(1(1)10)) post
marginsplot , yline(0, lcolor(red)) graphregion(color(white)) title(" ") xtitle(Decile of 1940 employment rate, size(large)) ytitle({&beta}: Agri support on patriotism (PCA)) ylab( , angle(0) format(%2.1f)) title("B. Employment and agri support", size(huge))
graph export "results/figures/AppFig3B-margins-aaa-e40.pdf", replace as(pdf)

xi: reg pc1 c.iNDEXP_PC##i.c40w_10  $control if sample_ols == 1 & servicecommand != 7, r
margins , dydx(iNDEXP_PC) at(c40w_10=(1(1)10)) post
marginsplot , yline(0, lcolor(red)) graphregion(color(white)) title(" ") xtitle(Decile of 1939 average wage, size(large)) ytitle({&beta}: New Deal grants on patriotism (PCA)) ylab( , angle(0) format(%2.1f)) title("C. Income and New Deal grants", size(huge))
graph export "results/figures/AppFig3C-margins-ndexp-w39.pdf", replace as(pdf)

xi: reg pc1 c.iAGRI_PF##i.c40w_10  $control if sample_ols == 1 & servicecommand != 7, r
margins , dydx(iAGRI_PF) at(c40w_10=(1(1)10)) post
marginsplot , yline(0, lcolor(red)) graphregion(color(white)) title(" ") xtitle(Decile of 1939 average wage, size(large)) ytitle({&beta}: Agri support on patriotism (PCA)) ylab( , angle(0) format(%2.1f)) title("D. Income and agri support", size(huge))
graph export "results/figures/AppFig3D-margins-aaa-w39.pdf", replace as(pdf)

***************************************************************************************************
****         Fig 4. Heterogeneity: FDR support                                      		   ****
***************************************************************************************************
xi: reg pc1 c.iNDEXP_PC##i.fdr40_10  $control if sample_ols == 1 & servicecommand != 7, r
margins , dydx(iNDEXP_PC) at(fdr40_10=(1(1)10)) post
marginsplot , yline(0, lcolor(red)) graphregion(color(white)) title(" ") xtitle(Decile of 1940 Roosevelt support, size(large)) ytitle({&beta}: New Deal grants on patriotism (PCA)) ylab( , angle(0) format(%2.1f)) title("A. New Deal grants", size(huge))
graph export "results/figures/AppFig4A-margins-ndexp-fdr40.pdf", replace as(pdf)

xi: reg pc1 c.iAGRI_PF##i.fdr40_10    $control if sample_ols == 1 & servicecommand != 7, r
margins , dydx(iAGRI_PF) at(fdr40_10=(1(1)10)) post
marginsplot , yline(0, lcolor(red)) graphregion(color(white)) title(" ") xtitle(Decile of 1940 Roosevelt support, size(large)) ytitle({&beta}: Agri support on patriotism (PCA)) ylab( , angle(0) format(%2.1f)) title("B. Agricultural support", size(huge))
graph export "results/figures/AppFig4B-margins-aaa-fdr40.pdf", replace as(pdf)

***************************************************************************************************
****         Fig 5. Distribution of droughts                                        		   ****
***************************************************************************************************
format iSUM3MO_DROUGHT9732 iSUM3MO_DROUGHT3340 %2.1f 	
spmap  iSUM3MO_DROUGHT3340 using data/C-CountiesND_CA, id(_ID_CA) fcolor(Greys2) clnumber(9) ndocolor(none) ocolor(none ..)  ///
               legend( position(5) bplacement(sw) r(5))                                                                         ///
			line(data(data/C-USA_CA)) title(A. New Deal Droughts, size(*1.4))
graph export "results/figures/AppFig5A-map-droughts-ND.png", as(png) replace

spmap  iSUM3MO_DROUGHT9732 using data/C-CountiesND_CA, id(_ID_CA) fcolor(Greys2) clnumber(9) ndocolor(none) ocolor(none ..)  ///
               legend( position(5) bplacement(sw) r(5))                                                                         ///
			line(data(data/C-USA_CA)) title(B. Pre-New Deal Droughts, size(*1.4))
graph export "results/figures/AppFig5B-map-droughts-preND.png", as(png) replace


***************************************************************************************************
****         Fig 6. Heterogeneity: frontier experience                              		   ****
***************************************************************************************************
estimates clear 
local n 0
local dependents iwarbond_1944_PC ww2_vol_pop40 ww2_awards_pop40_is pc1

xtile frontier1 = tye_tfe890_500k_100_l6, n(2), if sample_ols == 1
xtile frontier2 = tye_tfe890_500k_100_l6, n(2), if sample_ols == 1 & servicecommand   !=   7

recode frontier1 frontier2 (1 = 0) (2 = 1)



foreach dependent of local dependents {
	if "`dependent'" == "iwarbond_1944_PC"    local splits = "frontier1==1 median_below1==0"
	if "`dependent'" == "ww2_vol_pop40"   	  local splits = "frontier2==1 frontier2==0"
	if "`dependent'" == "ww2_awards_pop40_is" local splits = "frontier2==1 frontier2==0"
	if "`dependent'" == "pc1"    			  local splits = "frontier2==1 frontier2==0"
	if "`dependent'" == "iwarbond_1944_PC"    local cond
	if "`dependent'" == "ww2_vol_pop40"       local cond              "& servicecommand != 7"
	if "`dependent'" == "ww2_awards_pop40_is" local cond              "& servicecommand != 7"
	if "`dependent'" == "pc1" 				  local cond              "& servicecommand != 7"

	foreach sample of local splits {
		local n = `n' + 1
		xi: reg `dependent' iAGRI_PF $control if sample_ols == 1 `cond' & `sample', r
		local b`n' =  _b[iAGRI_PF]
		local s`n' = _se[iAGRI_PF]
	} /* foreach sample */
} /* foreach dependent */

preserve
	clear
	set obs 8
	gen     x     = cond(mod(_n,2) == 1,_n,(_n-1)+0.4)  /* Odds are plotted at integer; evens are plotted at integer + 0.4 */
	gen     split = cond(mod(_n,2) == 1, 0,         1)  /* Odds are below median; evens are above median */
	gen b         = .
	gen s         = .
	forvalues n = 1(1)8 {
		replace b = `b`n'' if _n == `n'
		replace s = `s`n'' if _n == `n'
	} /* forvalues n */
	gen l = b - (1.96 * s)
	gen u = b + (1.96 * s)

	format b* %2.1f

	gen t     = 0.4
	gen title = cond(_n == 2,"{bf:War bonds}",cond(_n == 4,"{bf:Volunteers}",cond(_n == 6,"{bf:Medals}",cond(_n == 8,"{bf:PCA}",""))))
	gen x_t  = cond(_n == 2,1.2,cond(_n == 4,3.2,cond(_n == 6,5.2,cond(_n == 8,7.2,x))))
	
	graph twoway (scatter b    x if split == 0,  mcolor(red   )                  msize(*1.5) msymbol(oh))	           		  ///
				 (scatter b    x if split == 1,  mlcolor(green) mfcolor(none)    msize(*1.5) msymbol(oh))              		  ///
				 (rcap    l u  x if split == 0,    color(red  )                  msize(large)    lwidth(   thick))         	  ///
				 (rcap    l u  x if split == 1,    color(green)                  msize(medlarge) lwidth(medthick))         	  ///
				 (scatter t    x_t, mlabel(title        ) mlabcolor(black) mlabp(0) m(i) mlabsize(*1.2)) 	               	  ///
				, legend(order(3 "High" 4 "Low") rows(1) title("{bf: Level of frontier experience:}",  size(medium))) ///
				yline(0, lcolor(red)) xline(2.2, lcolor(black) lpattern(dash)) xline(4.2, lcolor(black) lpattern(dash)) 	  ///
				xline(6.2, lcolor(black) lpattern(dash)) ylabel(0(0.1)0.4, angle(0) labsize(medium) format(%2.1f)) 		      ///
				ytitle(OLS coefficient, size(normal)) xlabel(none) xtitle(" ") xscale(range(0.4 7.8)) graphregion(fcolor(white)) plotregion(fcolor(white)) scheme(s1manual)
									   
	graph export "results/figures/AppFig6-frontier.pdf", replace
restore

***************************************************************************************************
****         Fig 7. Plausibly Exogenous (Conley et al. 2012)                        		   ****
***************************************************************************************************
local level 0.9
foreach instrument in iSUM3MO_DROUGHT3340 iAGRI_T73{
	if "`instrument'" == "iAGRI_T73"           local instrument_title committee
	if "`instrument'" == "iAGRI_T73"           local explanation      "Tenure in Agriculture committee (i.h.s.): 1933-35"
	if "`instrument'" == "iAGRI_T73"           local cluster          DISTRICT_ID73
	if "`instrument'" == "iAGRI_T73"           local ivs              "iSUM3MO_DROUGHT3340 iAGRI_T73"
	if "`instrument'" == "iSUM3MO_DROUGHT3340" local instrument_title drought
	if "`instrument'" == "iSUM3MO_DROUGHT3340" local explanation      "Summer droughts (i.h.s.): 1933-40"
	if "`instrument'" == "iSUM3MO_DROUGHT3340" local cluster          CLIMDIVX
	if "`instrument'" == "iSUM3MO_DROUGHT3340" local ivs              "iAGRI_T73 iSUM3MO_DROUGHT3340"
	
	foreach dependent in iwarbond_1944_PC ww2_vol_pop40  ww2_awards_pop40_is pc1 { 
		if "`dependent'" == "iwarbond_1944_PC"    & "`instrument'" == "iSUM3MO_DROUGHT3340" local           title "A. War bonds"
		if "`dependent'" == "ww2_vol_pop40"       & "`instrument'" == "iSUM3MO_DROUGHT3340" local           title "B. Volunteers"
		if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iSUM3MO_DROUGHT3340" local           title "C. Medals"
		if "`dependent'" == "pc1"                 & "`instrument'" == "iSUM3MO_DROUGHT3340" local           title "D. PCA"
		if "`dependent'" == "iwarbond_1944_PC"    & "`instrument'" == "iAGRI_T73"           local           title "E. War bonds"
		if "`dependent'" == "ww2_vol_pop40"       & "`instrument'" == "iAGRI_T73"           local           title "F. Volunteers"
		if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iAGRI_T73"           local           title "G. Medals"
		if "`dependent'" == "pc1"                 & "`instrument'" == "iAGRI_T73"           local           title "H. PCA"
		if "`dependent'" == "iwarbond_1944_PC"    & "`instrument'" == "iSUM3MO_DROUGHT3340" local           lettr "A"
		if "`dependent'" == "ww2_vol_pop40"       & "`instrument'" == "iSUM3MO_DROUGHT3340" local           lettr "B"
		if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iSUM3MO_DROUGHT3340" local           lettr "C"
		if "`dependent'" == "pc1"                 & "`instrument'" == "iSUM3MO_DROUGHT3340" local           lettr "D"
		if "`dependent'" == "iwarbond_1944_PC"    & "`instrument'" == "iAGRI_T73"           local           lettr "E"
		if "`dependent'" == "ww2_vol_pop40"       & "`instrument'" == "iAGRI_T73"           local           lettr "F"
		if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iAGRI_T73"           local           lettr "G"
		if "`dependent'" == "pc1"                 & "`instrument'" == "iAGRI_T73"           local           lettr "H"

		if "`dependent'" == "iwarbond_1944_PC"    local dependent_title "warbonds"
		if "`dependent'" == "ww2_vol_pop40"       local dependent_title "volunteers"
		if "`dependent'" == "ww2_awards_pop40_is" local dependent_title "medals"
		if "`dependent'" == "pc1"                 local dependent_title "pca"
		
		                                                                                    local           gn 0.25
	    if "`dependent'" == "iwarbond_1944_PC"    & "`instrument'" == "iSUM3MO_DROUGHT3340" local           gx 1.4
		if "`dependent'" == "ww2_vol_pop40"       & "`instrument'" == "iSUM3MO_DROUGHT3340" local           gx 1.3
		if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iSUM3MO_DROUGHT3340" local           gx 1.2
		if "`dependent'" == "pc1"                 & "`instrument'" == "iSUM3MO_DROUGHT3340" local           gx 1.3
	    if "`dependent'" == "iwarbond_1944_PC"    & "`instrument'" == "iAGRI_T73"           local           gx 1.7
		if "`dependent'" == "ww2_vol_pop40"       & "`instrument'" == "iAGRI_T73"           local           gx 1.3
		if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iAGRI_T73"           local           gx 1.5
		if "`dependent'" == "pc1"                 & "`instrument'" == "iAGRI_T73"           local           gx 1.7

		if "`dependent'" == "iwarbond_1944_PC"    local if
		if "`dependent'" != "iwarbond_1944_PC"    local if "& servicecommand != 7"
		
		xi: reg `dependent' `ivs' $control if sample_ols == 1 `if'  
		local b  = _b[`instrument']
		local gn = -1 * `gn' * `b'
		local gx =      `gx' * `b'
		
		local rn = round(`gn',0.01)
		local rx = round(`gx',0.01)
		local st = round(`rx' / 4,0.01)
		
		ivreg2 `dependent' (iAGRI_PF = `ivs') $control if sample_ols == 1 `if', cluster(CLIMDIVX)
		local CI  = -invnormal((1 - `level')/2)
		local liv = _b[iAGRI_PF] - `CI'*_se[iAGRI_PF]
		local uiv = _b[iAGRI_PF] + `CI'*_se[iAGRI_PF]

		plausexog uci `dependent' $control (iAGRI_PF = `ivs') if sample_ols == 1 `if', vce(cluster CLIMDIVX) gmin(0 `gn') gmax(0 `gx') level(`level'*100) graph
		
		preserve
			clear
			set obs 3
			gen x   = cond(_n == 1,        `gn' , ///
			          cond(_n == 2,         0   , ///
					  cond(_n == 3,        `gx' ,.)))
			gen lci = cond(_n == 1,        `liv', ///
			          cond(_n == 2,        `liv', ///
					  cond(_n == 3,e(lb_iAGRI_PF),.)))
			gen uci = cond(_n == 1,e(ub_iAGRI_PF), ///
			          cond(_n == 2,        `uiv', ///
					  cond(_n == 3,        `uiv',.)))
					  
		    if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iSUM3MO_DROUGHT3340" local           rx 0.015
		    if "`dependent'" == "ww2_awards_pop40_is" & "`instrument'" == "iSUM3MO_DROUGHT3340" local           st 0.005
			twoway (line lci x, lpattern(dash) lcolor(black)) ///
			       (line uci x, lpattern(dash) lcolor(black)), ytitle("Estimated {&beta} for agri support") xtitle({&delta}) xline(`b', lcolor(blue)) yline(0, lcolor(red)) ///
				                                               ylabel( , angle(0) format(%9.2f)) xlabel(`rn' 0(`st')`rx', format(%9.3f))                                          ///
															   legend(order(1 "Union of confidence intervals")) title(`title', size(huge)) note(Instrument is: `explanation'.)  graphregion(color(white) lwidth(large)) scheme(s1color)
			graph export "results/figures/AppFig7`lettr'-conley2012-`dependent_title'-`instrument_title'.pdf" , replace as(pdf)
		restore
	} /* foreach instrument */	
} /* foreach dependent */	



***************************************************************************************************
****         Fig 8. Plausibly Exogenous (Conley et al. 2012): ASN                        	   ****
***************************************************************************************************

use "tmp/asn", clear

qui reghdfe vol  iAAA_PF_farmer iAAA_PF_farmhand   iSUM3MO_DROUGHT3340_farmer iSUM3MO_DROUGHT3340_farmhand   iAGRI_T73_farmer       iAGRI_T73_farmhand                              farmer farmhand $controls_asn                        , absorb(countyn)
gen insample = e(sample) == 1

local level 0.9
foreach instrument in iSUM3MO_DROUGHT3340_farmer  iAGRI_T73_farmer{
	if "`instrument'" == "iAGRI_T73_farmer"           local instrument_title committee
	if "`instrument'" == "iAGRI_T73_farmer"           local explanation      "Tenure in Agriculture committee (i.h.s.): 1933-35 {c 215} farmer"
	if "`instrument'" == "iAGRI_T73_farmer"           local ivs              "iSUM3MO_DROUGHT3340_farmer iAGRI_T73_farmer"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" local instrument_title drought
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" local explanation      "Summer droughts (i.h.s.): 1933-40 {c 215} farmer"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" local ivs              "iAGRI_T73_farmer iSUM3MO_DROUGHT3340_farmer"
	
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" 		local           title "B. Farmer"
	if "`instrument'" == "iAGRI_T73_farmer" 				local           title "E. Farmer"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" 		local           lettr "B"
	if "`instrument'" == "iAGRI_T73_farmer" 				local           lettr "E"
		
																	local           gn 0.75
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" 			    local           gx 1.7
	if "`instrument'" == "iAGRI_T73_farmer"  						local           gx 4
		
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmer" 				local           rxt 50
	if  "`instrument'" == "iAGRI_T73_farmer"  						local           rxt 130
		
		xi: reghdfe vol `ivs' farmer $controls_asn                      if insample == 1, cluster(countyn) absorb(countyn)
		local b  = _b[`instrument']
		local gn = -1 * `gn' * `b'
		local gx =      `gx' * `b'
		
		
		
		ivreghdfe  vol (iAGRI_PF_farmer = `ivs') farmer $controls_asn     if insample == 1, cluster(countyn) absorb(countyn)
		local CI  = -invnormal((1 - `level')/2)
		local liv = _b[iAGRI_PF_farmer] - `CI'*_se[iAGRI_PF_farmer]
		local uiv = _b[iAGRI_PF_farmer] + `CI'*_se[iAGRI_PF_farmer]

		plausexog uci vol $controls_asn farmer (iAGRI_PF_farmer = `ivs') i.countyn if insample == 1, vce(cluster countyn) gmin(0 `gn') gmax(0 `gx') level(`level'*100)
		
		preserve
			clear
			set obs 3
			gen x   = cond(_n == 1,        -10 , ///
			          cond(_n == 2,         0   , ///
					  cond(_n == 3,        `rxt' ,.)))
			gen lci = cond(_n == 1,        `liv', ///
			          cond(_n == 2,        `liv', ///
					  cond(_n == 3,e(lb_iAGRI_PF_farmer),.)))
			gen uci = cond(_n == 1,e(ub_iAGRI_PF_farmer), ///
			          cond(_n == 2,        `uiv', ///
					  cond(_n == 3,        `uiv',.)))
					  
			twoway (line lci x, lpattern(dash) lcolor(black)) ///
			       (line uci x, lpattern(dash) lcolor(black)), ytitle("Estimated {&beta} for agri support {c 215} farmer") xtitle({&delta}) xline(`b', lcolor(blue)) yline(0, lcolor(red)) 		///
				                                               ylabel(, angle(0)) xlabel(-10(10)`rxt')                                         ///
															   legend(order(1 "Union of confidence intervals")) title(`title', size(huge)) note(Instrument is: `explanation'.)  graphregion(color(white) lwidth(large)) scheme(s1color)
		
		graph export "results/figures/AppFig8`lettr'-conley2012-agri_farmer-`instrument_title'.pdf", replace as(pdf)
		restore
	} /* foreach instrument */	


local level 0.9
foreach instrument in iSUM3MO_DROUGHT3340_farmhand iAGRI_T73_farmhand {
	estimates clear
	if "`instrument'" == "iAGRI_T73_farmhand"             local instrument_title committee
	if "`instrument'" == "iAGRI_T73_farmhand"             local explanation      "Tenure in Agriculture committee (i.h.s.): 1933-35 {c 215} farm-hand"
	if "`instrument'" == "iAGRI_T73_farmhand"             local ivs              "iSUM3MO_DROUGHT3340_farmhand iAGRI_T73_farmhand"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand"   local instrument_title drought
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand"   local explanation      "Summer droughts (i.h.s.): 1933-40 {c 215} farm-hand"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand"   local ivs              "iAGRI_T73_farmhand iSUM3MO_DROUGHT3340_farmhand"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand"   local title 			 "C. Farm-hand"
    if "`instrument'" == "iAGRI_T73_farmhand" 			  local title 			 "F. Farm-hand"
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand"   local lettr 			 "C"
    if "`instrument'" == "iAGRI_T73_farmhand" 			  local lettr 			 "F"
	
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand" 															local           gn 1.3
	if  "`instrument'" == "iAGRI_T73_farmhand"  																	local           gn 1.3
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand" 															local           gx 2
	if  "`instrument'" == "iAGRI_T73_farmhand"  																	local           gx 8
	if "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand" 															local           rxt 60
	if  "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand" 															local           rnt -40
	if  "`instrument'" == "iSUM3MO_DROUGHT3340_farmhand" 															local           snt 10
	if  "`instrument'" == "iAGRI_T73_farmhand"  																	local           rnt -40
	if  "`instrument'" == "iAGRI_T73_farmhand"  																	local           rxt 180
	if  "`instrument'" == "iAGRI_T73_farmhand"  																	local           snt 20
		
		xi: reghdfe vol `ivs' farmhand $controls_asn                      if insample == 1, cluster(countyn) absorb(countyn)
		local b  =  _b[`instrument']
		local gn =   `gn' * `b'
		local gx =  -1 * `gx' * `b'
		
		ivreghdfe vol (iAGRI_PF_farmhand = `ivs') farmhand $controls_asn if insample == 1, absorb(countyn) cluster(countyn)
		local CI  = -invnormal((1 - `level')/2)
		local liv = _b[iAGRI_PF_farmhand] - `CI'*_se[iAGRI_PF_farmhand]
		local uiv = _b[iAGRI_PF_farmhand] + `CI'*_se[iAGRI_PF_farmhand]
		
		plausexog uci vol $controls_asn farmhand (iAGRI_PF_farmhand = `ivs') i.countyn if insample == 1, vce(cluster countyn) gmin(0 `gn') gmax(0 `gx') level(0.9)
		
		local lplaus = min( e(lb_iAGRI_PF_farmhand), e(ub_iAGRI_PF_farmhand))
		local uplaus = max(e(lb_iAGRI_PF_farmhand), e(ub_iAGRI_PF_farmhand))
		
		local lower1 = max(`liv', `lplaus')
		local lower3 = min(`liv', `lplaus')
		
		local upper1 = max(`uiv', `uplaus')
		local upper2 = min(`uiv', `uplaus')
		
		preserve
			clear
			set obs 3
			gen x   = cond(_n == 1,        -40 , ///
			          cond(_n == 2,         0   , ///
					  cond(_n == 3,        8,.)))
			gen lci = cond(_n == 1,      `lower1', ///
			          cond(_n == 2,      `lower1', ///
					  cond(_n == 3, 	 `lower3',.)))
			gen uci = cond(_n == 1, 	`upper1', ///
			          cond(_n == 2,      `upper2', ///
					  cond(_n == 3,      `upper2',.)))
					  
			twoway (line lci x, lpattern(dash) lcolor(black)) ///
			       (line uci x, lpattern(dash) lcolor(black)), ytitle("Estimated {&beta} for agri support {c 215} farm-hand") xtitle({&delta}) xline(`b', lcolor(blue)) yline(0, lcolor(red)) 		  ///
				                                               ylabel(, angle(0)) xlabel(-40 (5) 5)  	///
															   legend(order(1 "Union of confidence intervals")) title(`title', size(huge)) note(Instrument is: `explanation'.)  graphregion(color(white) lwidth(large)) scheme(s1color)
		
		graph export "results/figures/AppFig8`lettr'-conley2012-agri_farmhand-`instrument_title'.pdf", replace as(pdf)
		restore
	} /* foreach instrument */	
	
	
***************************************************************************************************
****         Fig 9. Matching Exercises                                              		   ****
***************************************************************************************************

xtile  nd_med = iNDEXP_PC, n(2)
gen nd_m = cond(nd_med == 2,1,0) if nd_med != .
cem ww1_vol_sh (0 .2875817 1) c30unemp (0 .0505954 1) c30urban MEAN9628		 ///
	(0 45 55 100) stateicpsr (#0) if nd_med != ., treatment(nd_m)
for VAR in var cem_strata cem_matched cem_weights : ren VAR nd_VAR


loc depvars iwarbond_1944_PC ww2_vol_pop40 ww2_awards_pop40_is pc1
loc specs ols bor entr cem nn

loc k = 1
foreach depvar in `depvars' {

	*Define regression conditions
	if `k' == 1	loc cond
	if `k' >= 2 loc cond "& servicecommand != 7"

	*Run ols, store results
	reg `depvar' iNDEXP_PC $control	if sample_ols == 1 `cond', robust
	loc ols_`depvar'_b = _b[iNDEXP_PC]
	loc ols_`depvar'_se = _se[iNDEXP_PC]
	
	*Run entropy matching, store results
	reg `depvar' iNDEXP_PC $control [aw=wiNDEXP_PC]							 ///
		if sample_ols == 1 `cond', robust
	loc entr_`depvar'_b = _b[iNDEXP_PC]
	loc entr_`depvar'_se = _se[iNDEXP_PC]

	*Run CEM, store results
	reg `depvar' iNDEXP_PC $control											 ///
		if sample_ols == 1 `cond' & nd_cem_match == 1, robust
	loc cem_`depvar'_b = _b[iNDEXP_PC]
	loc cem_`depvar'_se = _se[iNDEXP_PC]

	*Run Border FE, store results
	reg `depvar' iNDEXP_PC $control_nofe  i.closestbor_n					 ///
		if (sample_ols == 1 `cond' &										 ///
			(bor_n != . | dist2stateborder < 75)),							 ///
		robust
	loc bor_`depvar'_b = _b[iNDEXP_PC]
	loc bor_`depvar'_se = _se[iNDEXP_PC]
		
	*Run nearest neighbor, store results	
	nnmatch `depvar' nd_m lat_nd lon_nd ww1_vol_sh lpop30					 ///
		if sample_ols == 1 `cond',											 ///
		m(3) tc(att) exact(statei c30urban1)
	loc nn_`depvar'_b = _b[SATT]
	loc nn_`depvar'_se = _se[SATT]
	
	*Draw coefplots
	
	preserve
		clear
		set obs 5
		gen spec = .
		gen bhat = .
		gen ster = .
		gen upci = .
		gen loci = .
		loc j 	 = 0
		
		*Store estimates, se; calculate 95% CI
		foreach spec in `specs' {
			
			loc j = `j' + 1
			
			qui replace spec = `j'				  	  if _n == `j'
			qui replace bhat = ``spec'_`depvar'_b'    if _n == `j'
			qui replace ster = ``spec'_`depvar'_se'	  if _n == `j'
			qui replace upci = bhat + 1.645 * ster 	  if _n == `j'
			qui replace loci = bhat - 1.645 * ster 	  if _n == `j'

		} /* foreach spec */
		
		foreach sta in bhat ster upci loci {
			qui separate `sta', by(spec)
		} /*foreach sta */
		
		*Label models
		lab def slab 1 "OLS" 2 "Borders" 3 "Entropy" 4 "CEM" 5 "NN Match"
		lab val spec slab
		
		*Define graph title
		if `k' == 1 loc tit = "A. War Bonds"
		if `k' == 2 loc tit = "B. Volunteers"
		if `k' == 3 loc tit = "C. Medals"
		if `k' == 4 loc tit = "D. PCA"
		
		*Define graph range
		qui su upci
		loc yurn = `r(max)' + 0.01
		
		qui su loci
		loc ylrn =  min(`r(min)' - 0.01,0)
			
		*Plot graph
		twoway ///
			(scatter bhat1 spec if spec == 1, mcolor(dkgreen) mfcolor(none)	 ///
				msize(medlarge) msymbol(o))									 ///
			(scatter bhat2 spec if spec == 2, mcolor(dknavy) mfcolor(none)	 ///
				msize(medlarge) msymbol(o))									 ///
			(scatter bhat3 spec if spec == 3, mcolor(cranberry)				 ///
				mfcolor(none) msize(medlarge) msymbol(o))					 ///
			(scatter bhat4 spec if spec == 4, mcolor(dkorange) mfcolor(none) ///
				msize(medlarge) msymbol(o))									 ///
			(scatter bhat5 spec if spec == 5, mcolor(teal) mfcolor(none)	 ///
				msize(medlarge) msymbol(o))									 ///
			(rcap upci1 loci1 spec if spec == 1, blwidth(medthin)			 ///
					blpattern(solid) blcolor(dkgreen))						 ///
			(rcap upci2 loci2 spec if spec == 2, blwidth(medthin)			 ///
					blpattern(solid) blcolor(dknavy))						 ///
			(rcap upci3 loci3 spec if spec == 3, blwidth(medthin)			 ///
					blpattern(solid) blcolor(cranberry))					 ///
			(rcap upci4 loci4 spec if spec == 4, blwidth(medthin)			 ///
					blpattern(solid) blcolor(dkorange))						 ///
			(rcap upci5 loci5 spec if spec == 5, blwidth(medthin)			 ///
					blpattern(solid) blcolor(teal)),						 ///
			xlabel(none) xtitle("")											 ///					
			yscale(range(`ylrn' `yurn')) ylabel(#6, format(%3.2f)			 ///
				angle(0) labsize(*1.4))										 ///
			yline(0, lpattern(solid) lwidth(vthin) lcolor(red))				 ///
			title("`tit'", size(medlarge))                                   ///
			legend(order(1 "OLS (full sample)" 2 "Border FEs (border counties)" ///
				3 "Entropy" 4 "CEM" 5 "NN Match") 			                 ///
				title("Estimator:"))										 ///
			plotregion(fcolor(white)) graphregion(color(white))			     ///
			scheme(s1manual) name(g`k', replace)
	restore
	
	loc k = `k' + 1
} /* foraech depvar */

grc1leg g1 g2 g3 g4, leg(g1) position(6) ring(1) cols(2)					 ///
	plotregion(fcolor(white)) graphregion(fcolor(white))
graph export "results/figures/AppFig9-matching.pdf", as(pdf) replace

***************************************************************************************************
****         Fig 10. Drop one state at a time                                        		   ****
***************************************************************************************************
cap tab stateicpsr, gen(state)

set seed 20220209
gen random = runiform()
sort state random
gen     ninstate = 1                  if state != state[_n-1]
replace ninstate = ninstate[_n-1] + 1 if state == state[_n-1] & ninstate == .

replace state = "" if ninstate > 151

levelsof state if sample_ols == 1, local(states)
local n 0
foreach state of local states {	
	local ++n
	local state_`n' = "`state'"
	di "I'm working on state #`n'"
	
	qui {
		xi:  reg iwarbond_1944_PC       iAGRI_PF                                  $control if sample_ols == 1                           & state != "`state'", r
			local b_ols1_`n' =       _b[iAGRI_PF]
			local s_ols1_`n' =      _se[iAGRI_PF]
		xi:  reg ww2_vol_pop40          iAGRI_PF                                  $control if sample_ols == 1 & servicecommand   != 7   & state != "`state'", r
			local b_ols2_`n' =       _b[iAGRI_PF]
			local s_ols2_`n' =      _se[iAGRI_PF]
		xi:  reg ww2_awards_pop40_is    iAGRI_PF                                  $control if sample_ols == 1 & servicecommand   != 7   & state != "`state'", r
			local b_ols3_`n' =       _b[iAGRI_PF]
			local s_ols3_`n' =      _se[iAGRI_PF]
		xi:  reg pc1                    iAGRI_PF                                  $control if sample_ols == 1 & servicecommand   != 7   & state != "`state'", r
			local b_ols4_`n' =       _b[iAGRI_PF]
			local s_ols4_`n' =      _se[iAGRI_PF]
		
		
		xi:  ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1                          & state != "`state'", cluster(CLIMDIVX)
			local b_iv1_`n'  =        _b[iAGRI_PF]
			local s_iv1_`n'  =       _se[iAGRI_PF]
		xi:  ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7    & state != "`state'", cluster(CLIMDIVX)
			local b_iv2_`n'  =        _b[iAGRI_PF]
			local s_iv2_`n'  =       _se[iAGRI_PF]
		xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7    & state != "`state'", cluster(CLIMDIVX)
			local b_iv3_`n'  =        _b[iAGRI_PF]
			local s_iv3_`n'  =       _se[iAGRI_PF]
		xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7    & state != "`state'", cluster(CLIMDIVX)
			local b_iv4_`n'  =        _b[iAGRI_PF]
			local s_iv4_`n'  =       _se[iAGRI_PF]
	} /* qui */ 
} /* foreach state */ 

xi:  reg iwarbond_1944_PC       iAGRI_PF                                  $control if sample_ols == 1                      , r
	local b_ols1_49  =       _b[iAGRI_PF]
	local s_ols1_49  =      _se[iAGRI_PF]
xi:  reg ww2_vol_pop40          iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r
	local b_ols2_49  =       _b[iAGRI_PF]
	local s_ols2_49  =      _se[iAGRI_PF]
xi:  reg ww2_awards_pop40_is    iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r
	local b_ols3_49  =       _b[iAGRI_PF]
	local s_ols3_49  =      _se[iAGRI_PF]
xi:  reg pc1                    iAGRI_PF                                  $control if sample_ols == 1 & servicecommand != 7, r
	local b_ols4_49  =       _b[iAGRI_PF]
	local s_ols4_49  =      _se[iAGRI_PF]

	
xi:  ivreg2 iwarbond_1944_PC    (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1                      , cluster(CLIMDIVX)
	local b_iv1_49   =        _b[iAGRI_PF]
	local s_iv1_49   =       _se[iAGRI_PF]
xi:  ivreg2 ww2_vol_pop40       (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
	local b_iv2_49   =        _b[iAGRI_PF]
	local s_iv2_49   =       _se[iAGRI_PF]
xi:  ivreg2 ww2_awards_pop40_is (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
	local b_iv3_49   =        _b[iAGRI_PF]
	local s_iv3_49   =       _se[iAGRI_PF]
xi:  ivreg2 pc1                 (iAGRI_PF = iSUM3MO_DROUGHT3340 iAGRI_T73) $control if sample_ols == 1 & servicecommand != 7, cluster(CLIMDIVX)
	local b_iv4_49   =        _b[iAGRI_PF]
	local s_iv4_49   =       _se[iAGRI_PF]
	
local state_49  = "None"

clear
set obs 50
gen     n = _n
gen ICPSR_STATENAME = ""
forvalues dep = 1(1)4 {
	foreach spec in ols iv {
		gen b_`spec'`dep' = .
		gen s_`spec'`dep' = .
		forvalues n = 1(1)49 {
			replace ICPSR_STATENAME = "`state_`n''"       if _n == `n'
			replace b_`spec'`dep'   = `b_`spec'`dep'_`n'' if _n == `n' 
			replace s_`spec'`dep'   = `s_`spec'`dep'_`n'' if _n == `n'
		} /* forvalues n */
		gen h_`spec'`dep'   = b_`spec'`dep' + 1.96 * s_`spec'`dep' 
		gen l_`spec'`dep'   = b_`spec'`dep' - 1.96 * s_`spec'`dep'
	} /* foreach spec */
} /* forvalues dep */


rename ICPSR_STATENAME state
merge 1:1 state using rawdata/ICPSR/ICPSR-States, nogen keepus(stateabb) keep(mas mat) /* not matched ICPSR_STATENAME = Full */

replace stateabb = "None" if state == "Full"

replace n = -3 if n == 49
sort    n
replace n = n[_n-1] + 2 if n > 1 

graph twoway (scatter  b_ols1        n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_ols1 h_ols1 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.05)0.15, angle(0) labsize(*1.2) format(%3.2f)) title(A. OLS: War bonds, size(vlarge)) name(g1, replace)
graph export "results/figures/AppFig10A-drop1state-ols-warbonds.pdf", replace as(pdf)

graph twoway (scatter  b_ols2        n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_ols2 h_ols2 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.02)0.04, angle(0) labsize(*1.2) format(%4.2f)) title(B. OLS: Volunteers, size(vlarge)) name(g2, replace)
graph export "results/figures/AppFig10B-drop1state-ols-volunteers.pdf", replace as(pdf)


graph twoway (scatter  b_ols3        n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_ols3 h_ols3 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.005)0.015, angle(0) labsize(*1.2) format(%4.3f)) title(C. OLS: Medals, size(vlarge)) name(g3, replace)
graph export "results/figures/AppFig10C-drop1state-ols-medals.pdf", replace as(pdf)
	  
graph twoway (scatter  b_ols4        n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_ols4 h_ols4 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.1)0.2, angle(0) labsize(*1.2) format(%3.2f)) title(D. OLS: PCA, size(vlarge)) name(g4, replace)
graph export "results/figures/AppFig10D-drop1state-ols-pca.pdf", replace as(pdf)


graph twoway (scatter  b_iv1       n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_iv1 h_iv1 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.25)0.5, angle(0) labsize(*1.2) format(%3.1f)) title(E. IV: War bonds, size(vlarge)) name(g5, replace)
graph export "results/figures/AppFig10E-drop1state-iv-warbonds.pdf", replace as(pdf)

graph twoway (scatter  b_iv2       n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_iv2 h_iv2 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.15)0.3, angle(0) labsize(*1.2) format(%3.2f)) title(F. IV: Volunteers, size(vlarge)) name(g6, replace)
graph export "results/figures/AppFig10F-drop1state-iv-volunteers.pdf", replace as(pdf)


graph twoway (scatter  b_iv3       n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_iv3 h_iv3 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.025)0.075, angle(0) labsize(*1.2) format(%4.3f)) title(G. IV: Medals, size(vlarge)) name(g7, replace)
graph export "results/figures/AppFig10G-drop1state-iv-medals.pdf", replace as(pdf)

graph twoway (scatter  b_iv4       n  ,  color(black) msize(medlarge)               )         ///
			 (rcap     l_iv4 h_iv4 n, color(black) msize(medlarge) lwidth(medthick) ),        ///
	  legend(off) graphregion(color(white)) xtitle("State excluded", size(vlarge)) ytitle("")   /// 
	  yline(0, lcolor(red)) xlabel(-3 "None" 1 "AL" 3 "AZ" 5 "AR" 7 "CA" 9 "CO" 11 "CT" 13 "DE" 15 "DC" 17 "FL" 19 "GA" 21 "ID" 23 "IL" 25 "IN" 27 "IA" 29 "KS" 31 "KY" 33 "LA" 35 "ME" 37 "MD" 39 "MA" 41 "MI" 43 "MN" 45 "MS" 47 "MO" 49 "MT" 51 "NE" 53 "NV" 55 "NH" 57 "NJ" 59 "NM" 61 "NY" 63 "NC" 65 "ND" 67 "OH" 69 "OK" 71 "OR" 73 "PA" 75 "RI" 77 "SC" 79 "SD" 81 "TN" 83 "TX" 85 "UT" 87 "VT" 89 "VA" 91 "WA" 93 "WV" 95 "WI" 97 "WY" , noticks valuelabel labsize(*0.7) alt)                    ///
	  ylabel(0(0.5)1, angle(0) labsize(*1.2) format(%3.1f)) title(H. IV: PCA, size(vlarge)) name(g8, replace)
graph export "results/figures/AppFig10H-drop1state-iv-pca.pdf", replace as(pdf)

***************************************************************************************************
****    III. Erase junk                                                                        ****
***************************************************************************************************
foreach cut in 200 400 600 800 1000 { 	
	erase "tmp/moransi_`cut'.dta"
} /* foreach cut */

rmdir "tmp/"

log close
exit